/// <summary> /// Get unit abbreviation string. /// </summary> /// <param name="unit">Unit to get abbreviation for.</param> /// <returns>Unit abbreviation string.</returns> public static string GetAbbreviation(ForceChangeRateUnit unit) { return(GetAbbreviation(unit, null)); }
/// <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(ForceChangeRateUnit unit, [CanBeNull] string cultureName) { IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); return(UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider)); }
/// <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(ForceChangeRateUnit unit) { return(ToString(unit, null, 2)); }
/// <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(ForceChangeRateUnit unit, [CanBeNull] Culture culture) { return(ToString(unit, culture, 2)); }
/// <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(ForceChangeRateUnit unit, [CanBeNull] IFormatProvider provider) { return(ToString(unit, provider, 2)); }
public static string GetAbbreviation(ForceChangeRateUnit unit, [CanBeNull] Culture culture) { return(UnitSystem.GetCached(culture).GetDefaultAbbreviation(unit)); }
/// <summary> /// Converts this ForceChangeRate to another ForceChangeRate with the unit representation <paramref name="unit" />. /// </summary> /// <returns>A ForceChangeRate with the specified unit.</returns> public ForceChangeRate ToUnit(ForceChangeRateUnit unit) { var convertedValue = AsBaseNumericType(unit); return(new ForceChangeRate(convertedValue, unit)); }
/// <summary> /// Dynamically convert from value and unit enum <see cref="ForceChangeRateUnit" /> to <see cref="ForceChangeRate" />. /// </summary> /// <param name="value">Value to convert from.</param> /// <param name="fromUnit">Unit to convert from.</param> /// <returns>ForceChangeRate unit value.</returns> public static ForceChangeRate?From(QuantityValue?value, ForceChangeRateUnit fromUnit) { return(value.HasValue ? new ForceChangeRate((double)value.Value, fromUnit) : default(ForceChangeRate?)); }
public static bool TryParseUnit(string str, out ForceChangeRateUnit unit) { return(TryParseUnit(str, null, out unit)); }
/// <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 ForceChangeRateUnit unit) { IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); return(UnitParser.Default.TryParse <ForceChangeRateUnit>(str, provider, out unit)); }
public static ForceChangeRate From(double value, ForceChangeRateUnit fromUnit) { return(new ForceChangeRate((double)value, fromUnit)); }
public static ForceChangeRate From(QuantityValue value, ForceChangeRateUnit fromUnit) #endif { return(new ForceChangeRate((double)value, fromUnit)); }
public static ForceChangeRate From(double value, ForceChangeRateUnit fromUnit)
ForceChangeRate(double numericValue, ForceChangeRateUnit unit) { _value = numericValue; _unit = unit; }
public static ForceChangeRate From(decimal value, ForceChangeRateUnit fromUnit) { return(new ForceChangeRate((decimal)value, fromUnit)); }