ApparentEnergy(double numericValue, ApparentEnergyUnit unit) { _value = numericValue; _unit = 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(ApparentEnergyUnit unit) { return(ToString(unit, null, 2)); }
public static string GetAbbreviation( ApparentEnergyUnit unit, #if WINDOWS_UWP [CanBeNull] string cultureName)
public static string GetAbbreviation(ApparentEnergyUnit unit, [CanBeNull] Culture culture) { return(UnitSystem.GetCached(culture).GetDefaultAbbreviation(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="culture">Culture to use for localization and number formatting.</param> /// <returns>String representation.</returns> public string ToString(ApparentEnergyUnit unit, [CanBeNull] Culture culture) { return(ToString(unit, culture, 2)); }
public static string GetAbbreviation(ApparentEnergyUnit unit) { return(GetAbbreviation(unit, null)); }
/// <summary> /// Convert to the unit representation <paramref name="unit" />. /// </summary> /// <returns>Value converted to the specified unit.</returns> public double As(ApparentEnergyUnit unit) => GetValueAs(unit);
/// <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(ApparentEnergyUnit unit, [CanBeNull] string cultureName) { IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); return(UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider)); }
public static ApparentEnergy From(double value, ApparentEnergyUnit fromUnit) { return(new ApparentEnergy((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="provider">Format to use for localization and number formatting. Defaults to <see cref="UnitSystem.DefaultCulture" />.</param> /// <returns>String representation.</returns> public string ToString(ApparentEnergyUnit unit, [CanBeNull] IFormatProvider provider) { return(ToString(unit, provider, 2)); }
public static ApparentEnergy?From(QuantityValue?value, ApparentEnergyUnit fromUnit) { return(value.HasValue ? new ApparentEnergy((double)value.Value, fromUnit) : default(ApparentEnergy?)); }
public static string GetAbbreviation(ApparentEnergyUnit unit, [CanBeNull] IFormatProvider provider) { provider = provider ?? UnitSystem.DefaultCulture; return(UnitSystem.GetCached(provider).GetDefaultAbbreviation(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 ApparentEnergy(double value, ApparentEnergyUnit unit) { _value = value; _unit = 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 ApparentEnergy ToUnit(ApparentEnergyUnit unit) { var convertedValue = GetValueAs(unit); return(new ApparentEnergy(convertedValue, unit)); }
public static ApparentEnergy From(double value, ApparentEnergyUnit fromUnit)
public static bool TryParseUnit(string str, out ApparentEnergyUnit unit) { return(TryParseUnit(str, null, out unit)); }
public static ApparentEnergy From(QuantityValue value, ApparentEnergyUnit fromUnit) #endif { return(new ApparentEnergy((double)value, fromUnit)); }
/// <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 ApparentEnergyUnit unit) { IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); return(UnitParser.Default.TryParse <ApparentEnergyUnit>(str, provider, out unit)); }
/// <summary> /// Converts this ApparentEnergy to another ApparentEnergy with the unit representation <paramref name="unit" />. /// </summary> /// <returns>A ApparentEnergy with the specified unit.</returns> public ApparentEnergy ToUnit(ApparentEnergyUnit unit) { var convertedValue = AsBaseNumericType(unit); return(new ApparentEnergy(convertedValue, unit)); }
public static void HasConversion(this PropertyBuilder <ApparentEnergy> propertyBuilder, ApparentEnergyUnit unit) => propertyBuilder.HasConversion(v => v.As(unit), v => new ApparentEnergy(v, unit));