예제 #1
0
        /// <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;
        }
예제 #2
0
 /// <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());
 }
예제 #3
0
 public static DistanceConversion ConvertFrom(this double value, DistanceUnit unit)
 {
     return(new DistanceConversion(value * unit.GetConversionFactor()));
 }
예제 #4
0
 public static double ConvertTo(this double metres, DistanceUnit unit)
 {
     return(metres / unit.GetConversionFactor());
 }
예제 #5
0
 public static DistanceConversion ConvertFrom(this double value, DistanceUnit unit)
 {
     return new DistanceConversion(value * unit.GetConversionFactor());
 }
예제 #6
0
 public static double ConvertTo(this double metres, DistanceUnit unit)
 {
     return metres / unit.GetConversionFactor();
 }