/// <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)); }
public static RotationalSpeed From(decimal value, RotationalSpeedUnit fromUnit) { return(new RotationalSpeed((decimal)value, fromUnit)); }
public static string GetAbbreviation(RotationalSpeedUnit unit, [CanBeNull] Culture culture) { return(UnitSystem.GetCached(culture).GetDefaultAbbreviation(unit)); }
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)); }
/// <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)); }
public static string GetAbbreviation(RotationalSpeedUnit unit, CultureInfo culture = null) { return(UnitSystem.GetCached(culture).GetDefaultAbbreviation(unit)); }
/// <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)); }
/// <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)); }
/// <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; }
/// <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);
/// <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)); }
public static string GetAbbreviation( RotationalSpeedUnit unit, #if WINDOWS_UWP [CanBeNull] string cultureName)
public static bool TryParseUnit(string str, out RotationalSpeedUnit unit) { return(TryParseUnit(str, null, out unit)); }
public string ToString(RotationalSpeedUnit unit, CultureInfo culture = null, int significantDigitsAfterRadix = 2) { return(ToString(unit, culture, UnitFormatter.GetFormat(As(unit), significantDigitsAfterRadix))); }
/// <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)); }
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?)); }
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)); }
public static RotationalSpeed From(QuantityValue value, RotationalSpeedUnit fromUnit) #endif { return(new RotationalSpeed((double)value, fromUnit)); }
/// <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)); }
public static RotationalSpeed From(double value, RotationalSpeedUnit fromUnit)
/// <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)); }
public static void HasConversion(this PropertyBuilder <RotationalSpeed> propertyBuilder, RotationalSpeedUnit unit) => propertyBuilder.HasConversion(v => v.As(unit), v => new RotationalSpeed(v, unit));