Example #1
0
        /// <summary>
        ///     Get unit abbreviation string.
        /// </summary>
        /// <param name="unit">Unit to get abbreviation for.</param>
        /// <returns>Unit abbreviation string.</returns>
        /// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
        public static string GetAbbreviation(RotationalSpeedUnit unit, [CanBeNull] string cultureName)
        {
            IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);

            return(UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider));
        }
Example #2
0
 public static RotationalSpeed From(decimal value, RotationalSpeedUnit fromUnit)
 {
     return(new RotationalSpeed((decimal)value, fromUnit));
 }
Example #3
0
 public static string GetAbbreviation(RotationalSpeedUnit unit, [CanBeNull] Culture culture)
 {
     return(UnitSystem.GetCached(culture).GetDefaultAbbreviation(unit));
 }
Example #4
0
 public string ToString(RotationalSpeedUnit unit, CultureInfo culture = null)
 {
     return(ToString(unit, culture, "{0:0.##} {1}"));
 }
        public static string GetAbbreviation(RotationalSpeedUnit unit, [CanBeNull] IFormatProvider provider)
        {
            provider = provider ?? UnitSystem.DefaultCulture;

            return(UnitSystem.GetCached(provider).GetDefaultAbbreviation(unit));
        }
Example #6
0
 /// <summary>
 ///     Get string representation of value and unit. Using current UI culture and two significant digits after radix.
 /// </summary>
 /// <param name="unit">Unit representation to use.</param>
 /// <returns>String representation.</returns>
 public string ToString(RotationalSpeedUnit unit)
 {
     return(ToString(unit, null, 2));
 }
Example #7
0
 public static string GetAbbreviation(RotationalSpeedUnit unit, CultureInfo culture = null)
 {
     return(UnitSystem.GetCached(culture).GetDefaultAbbreviation(unit));
 }
Example #8
0
        /// <summary>
        ///     Converts this RotationalSpeed to another RotationalSpeed with the unit representation <paramref name="unit" />.
        /// </summary>
        /// <returns>A RotationalSpeed with the specified unit.</returns>
        public RotationalSpeed ToUnit(RotationalSpeedUnit unit)
        {
            var convertedValue = AsBaseNumericType(unit);

            return(new RotationalSpeed(convertedValue, unit));
        }
Example #9
0
        /// <summary>
        ///     Converts this Duration to another Duration with the unit representation <paramref name="unit" />.
        /// </summary>
        /// <returns>A Duration with the specified unit.</returns>
        public RotationalSpeed ToUnit(RotationalSpeedUnit unit)
        {
            var convertedValue = GetValueAs(unit);

            return(new RotationalSpeed(convertedValue, unit));
        }
Example #10
0
 /// <summary>
 ///     Creates the quantity with the given numeric value and unit.
 /// </summary>
 /// <param name="value">The numeric value to construct this quantity with.</param>
 /// <param name="unit">The unit representation to construct this quantity with.</param>
 /// <exception cref="ArgumentException">If value is NaN or Infinity.</exception>
 public RotationalSpeed(double value, RotationalSpeedUnit unit)
 {
     _value = value;
     _unit  = unit;
 }
Example #11
0
 /// <summary>
 ///     Convert to the unit representation <paramref name="unit" />.
 /// </summary>
 /// <returns>Value converted to the specified unit.</returns>
 public double As(RotationalSpeedUnit unit) => GetValueAs(unit);
Example #12
0
 /// <summary>
 ///     Dynamically convert from value and unit enum <see cref="RotationalSpeedUnit" /> to <see cref="RotationalSpeed" />.
 /// </summary>
 /// <param name="value">Value to convert from.</param>
 /// <param name="fromUnit">Unit to convert from.</param>
 /// <returns>RotationalSpeed unit value.</returns>
 public static RotationalSpeed From(double value, RotationalSpeedUnit fromUnit)
 {
     return(new RotationalSpeed(value, fromUnit));
 }
Example #13
0
        public static string GetAbbreviation(
            RotationalSpeedUnit unit,
#if WINDOWS_UWP
            [CanBeNull] string cultureName)
Example #14
0
 public static bool TryParseUnit(string str, out RotationalSpeedUnit unit)
 {
     return(TryParseUnit(str, null, out unit));
 }
Example #15
0
 public string ToString(RotationalSpeedUnit unit, CultureInfo culture = null, int significantDigitsAfterRadix = 2)
 {
     return(ToString(unit, culture, UnitFormatter.GetFormat(As(unit), significantDigitsAfterRadix)));
 }
Example #16
0
        /// <summary>
        ///     Parse a unit string.
        /// </summary>
        /// <param name="str">String to parse. Typically in the form: {number} {unit}</param>
        /// <param name="unit">The parsed unit if successful.</param>
        /// <returns>True if successful, otherwise false.</returns>
        /// <example>
        ///     Length.TryParseUnit("m", new CultureInfo("en-US"));
        /// </example>
        /// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
        public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out RotationalSpeedUnit unit)
        {
            IFormatProvider provider = GetFormatProviderFromCultureName(cultureName);

            return(UnitParser.Default.TryParse <RotationalSpeedUnit>(str, provider, out unit));
        }
Example #17
0
 public string ToString(RotationalSpeedUnit unit, CultureInfo culture, string format, params object[] args)
 {
     return(string.Format(culture, format, UnitFormatter.GetFormatArgs(unit, As(unit), culture, args)));
 }
 /// <summary>
 ///     Dynamically convert from value and unit enum <see cref="RotationalSpeedUnit" /> to <see cref="RotationalSpeed" />.
 /// </summary>
 /// <param name="value">Value to convert from.</param>
 /// <param name="fromUnit">Unit to convert from.</param>
 /// <returns>RotationalSpeed unit value.</returns>
 public static RotationalSpeed?From(QuantityValue?value, RotationalSpeedUnit fromUnit)
 {
     return(value.HasValue ? new RotationalSpeed((double)value.Value, fromUnit) : default(RotationalSpeed?));
 }
Example #19
0
 RotationalSpeed(double numericValue, RotationalSpeedUnit unit)
 {
     _value = numericValue;
     _unit  = unit;
 }
 /// <summary>
 ///     Get string representation of value and unit. Using two significant digits after radix.
 /// </summary>
 /// <param name="unit">Unit representation to use.</param>
 /// <param name="provider">Format to use for localization and number formatting. Defaults to <see cref="UnitSystem.DefaultCulture" />.</param>
 /// <returns>String representation.</returns>
 public string ToString(RotationalSpeedUnit unit, [CanBeNull] IFormatProvider provider)
 {
     return(ToString(unit, provider, 2));
 }
Example #21
0
        public static RotationalSpeed From(QuantityValue value, RotationalSpeedUnit fromUnit)
#endif
        {
            return(new RotationalSpeed((double)value, fromUnit));
        }
Example #22
0
 /// <summary>
 ///     Get string representation of value and unit. Using two significant digits after radix.
 /// </summary>
 /// <param name="unit">Unit representation to use.</param>
 /// <param name="culture">Culture to use for localization and number formatting.</param>
 /// <returns>String representation.</returns>
 public string ToString(RotationalSpeedUnit unit, [CanBeNull] Culture culture)
 {
     return(ToString(unit, culture, 2));
 }
Example #23
0
 public static RotationalSpeed From(double value, RotationalSpeedUnit fromUnit)
Example #24
0
 /// <summary>
 ///     Get unit abbreviation string.
 /// </summary>
 /// <param name="unit">Unit to get abbreviation for.</param>
 /// <returns>Unit abbreviation string.</returns>
 public static string GetAbbreviation(RotationalSpeedUnit unit)
 {
     return(GetAbbreviation(unit, null));
 }
Example #25
0
 public static void HasConversion(this PropertyBuilder <RotationalSpeed> propertyBuilder, RotationalSpeedUnit unit) =>
 propertyBuilder.HasConversion(v => v.As(unit), v => new RotationalSpeed(v, unit));