/// <summary> /// Creates a new Distance expressed in a specified unit. /// </summary> /// <param name="value">The value of the distance.</param> /// <param name="unit">The unit in which the value is expressed.</param> public Distance(double value, DistanceUnit unit) : base(new Data.Native.NativeDataContainer()) { // Converts and stores the value in meters. double convertedValue = value / unit.GetConversionFactor(); ((Data.Native.NativeDataContainer)DataContainer)["value"] = convertedValue; }
/// <summary> /// Gets the value of the distance with a given unit. /// </summary> /// <param name="unit">The unit to query for.</param> /// <returns>The double value of the distance.</returns> public double ValueAs(DistanceUnit unit) { return(Value * unit.GetConversionFactor()); }
public static DistanceConversion ConvertFrom(this double value, DistanceUnit unit) { return(new DistanceConversion(value * unit.GetConversionFactor())); }
public static double ConvertTo(this double metres, DistanceUnit unit) { return(metres / unit.GetConversionFactor()); }
public static DistanceConversion ConvertFrom(this double value, DistanceUnit unit) { return new DistanceConversion(value * unit.GetConversionFactor()); }
public static double ConvertTo(this double metres, DistanceUnit unit) { return metres / unit.GetConversionFactor(); }