コード例 #1
0
        public void ConversionRoundTrip()
        {
            Duration second = Duration.FromSeconds(1);

            AssertEx.EqualTolerance(1, Duration.FromDays(second.Days).Seconds, DaysTolerance);
            AssertEx.EqualTolerance(1, Duration.FromHours(second.Hours).Seconds, HoursTolerance);
            AssertEx.EqualTolerance(1, Duration.FromMicroseconds(second.Microseconds).Seconds, MicrosecondsTolerance);
            AssertEx.EqualTolerance(1, Duration.FromMilliseconds(second.Milliseconds).Seconds, MillisecondsTolerance);
            AssertEx.EqualTolerance(1, Duration.FromMinutes(second.Minutes).Seconds, MinutesTolerance);
            AssertEx.EqualTolerance(1, Duration.FromMonths30(second.Months30).Seconds, Months30Tolerance);
            AssertEx.EqualTolerance(1, Duration.FromNanoseconds(second.Nanoseconds).Seconds, NanosecondsTolerance);
            AssertEx.EqualTolerance(1, Duration.FromSeconds(second.Seconds).Seconds, SecondsTolerance);
            AssertEx.EqualTolerance(1, Duration.FromWeeks(second.Weeks).Seconds, WeeksTolerance);
            AssertEx.EqualTolerance(1, Duration.FromYears365(second.Years365).Seconds, Years365Tolerance);
        }
コード例 #2
0
 /// <inheritdoc cref="Duration.FromMicroseconds(double?)"/>
 public static Duration?Microseconds(this decimal?value) => Duration.FromMicroseconds(value == null ? (double?)null : Convert.ToDouble(value.Value));
コード例 #3
0
 /// <inheritdoc cref="Duration.FromMicroseconds(double)"/>
 public static Duration Microseconds(this decimal value) => Duration.FromMicroseconds(Convert.ToDouble(value));
コード例 #4
0
 /// <inheritdoc cref="Duration.FromMicroseconds(double?)"/>
 public static Duration?Microseconds(this float?value) => Duration.FromMicroseconds(value);
コード例 #5
0
 /// <inheritdoc cref="Duration.FromMicroseconds(double?)"/>
 public static Duration?Microseconds(this double?value) => Duration.FromMicroseconds(value);
コード例 #6
0
 /// <inheritdoc cref="Duration.FromMicroseconds(double)"/>
 public static Duration Microseconds(this long value) => Duration.FromMicroseconds(value);
コード例 #7
0
 public static Duration Microseconds <T>(this T value) =>
 Duration.FromMicroseconds(Convert.ToDouble(value));
コード例 #8
0
 public void NumberToMicrosecondsTest() =>
 Assert.Equal(Duration.FromMicroseconds(2), 2.Microseconds());
コード例 #9
0
 public static Duration?Microseconds <T>(this T?value) where T : struct => Duration.FromMicroseconds(value == null ? (double?)null : Convert.ToDouble(value.Value));