Exemple #1
0
 /// <summary>
 /// Converts meters/s to km/h or miles/h depending on the <paramref name="localeId"/>.
 /// </summary>
 /// <param name="localeId">The locale ID.</param>
 /// <param name="metersPerSecond">The amount of speed.</param>
 /// <returns>The converted amount of speed.</returns>
 public static double GetSpeed(string localeId, int metersPerSecond)
 {
     if (string.IsNullOrEmpty(localeId))
     {
         throw new ArgumentException("localeId");
     }
     return(GetRegion(localeId).IsMetric
         ? UnitConversionCalculator.ConvertMetersPerSecondToKilometersPerHour(metersPerSecond)
         : UnitConversionCalculator.ConvertMetersPerSecondToMilesPerHour(metersPerSecond));
 }
Exemple #2
0
 /// <summary>
 /// Converts meters to km or miles depending on the <paramref name="localeId"/>.
 /// </summary>
 /// <param name="localeId">The locale ID.</param>
 /// <param name="meters">The amount of distance.</param>
 /// <returns>The converted amount of distance.</returns>
 public static double GetDistance(string localeId, int meters)
 {
     return(GetRegion(localeId).IsMetric ? meters * UnitConversionCalculator.KilometersPerMeter : UnitConversionCalculator.ConvertMetersToMiles(meters));
 }
Exemple #3
0
 /// <summary>
 /// Converts kilograms to kg or pound depending on the <paramref name="localeId"/>.
 /// </summary>
 /// <param name="localeId">The locale ID.</param>
 /// <param name="kiloGrams">The amount of weight.</param>
 /// <returns>The converted amount of weight.</returns>
 public static double GetWeight(string localeId, int kiloGrams)
 {
     return(GetRegion(localeId).IsMetric ? kiloGrams : UnitConversionCalculator.ConvertKilogramToPounds(kiloGrams));
 }
Exemple #4
0
 /// <summary>
 /// Converts meters to meters or yards depending on the <paramref name="localeId"/>.
 /// </summary>
 /// <param name="localeId">The locale ID.</param>
 /// <param name="meters">The amount of distance.</param>
 /// <returns>The converted amount of distance.</returns>
 public static double GetSmallDistance(string localeId, int meters)
 {
     return(GetRegion(localeId).IsMetric ? meters : UnitConversionCalculator.ConvertMetersToYards(meters));
 }
Exemple #5
0
 /// <summary>
 /// Converts centimeters to cm or inch depending on the <paramref name="localeId"/>.
 /// </summary>
 /// <param name="localeId">The locale ID.</param>
 /// <param name="centiMeters">The amount of height.</param>
 /// <returns>The converted amount of height.</returns>
 public static double GetHeight(string localeId, int centiMeters)
 {
     return(GetRegion(localeId).IsMetric ? centiMeters : UnitConversionCalculator.ConvertCentimetersToInches(centiMeters));
 }
Exemple #6
0
 /// <summary>
 /// Converts meters to m or ft depending on the <paramref name="localeId"/>.
 /// </summary>
 /// <param name="localeId">The locale ID.</param>
 /// <param name="meters">The amount of altitude.</param>
 /// <returns>The converted amount of altitude.</returns>
 public static double GetAltitude(string localeId, int meters)
 {
     return(GetRegion(localeId).IsMetric ? meters : UnitConversionCalculator.ConvertMetersToFeet(meters));
 }