/// <summary> /// Converts this Duration to another Duration with the unit representation <paramref name="unit" />. /// </summary> /// <returns>A Duration with the specified unit.</returns> public ApparentPower ToUnit(ApparentPowerUnit unit) { var convertedValue = GetValueAs(unit); return(new ApparentPower(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 ApparentPower(double value, ApparentPowerUnit unit) { _value = value; _unit = unit; }
/// <summary> /// Dynamically convert from value and unit enum <see cref="ApparentPowerUnit" /> to <see cref="ApparentPower" />. /// </summary> /// <param name="value">Value to convert from.</param> /// <param name="fromUnit">Unit to convert from.</param> /// <returns>ApparentPower unit value.</returns> public static ApparentPower From(double value, ApparentPowerUnit fromUnit) { return(new ApparentPower(value, fromUnit)); }
/// <summary> /// Convert to the unit representation <paramref name="unit" />. /// </summary> /// <returns>Value converted to the specified unit.</returns> public double As(ApparentPowerUnit unit) => GetValueAs(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 ApparentPowerUnit unit) { IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); return(UnitParser.Default.TryParse <ApparentPowerUnit>(str, provider, out unit)); }
public static bool TryParseUnit(string str, out ApparentPowerUnit unit) { return(TryParseUnit(str, null, out unit)); }
public static void HasConversion(this PropertyBuilder <ApparentPower> propertyBuilder, ApparentPowerUnit unit) => propertyBuilder.HasConversion(v => v.As(unit), v => new ApparentPower(v, 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="cultureName">Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to <see cref="UnitSystem" />'s default culture.</param> /// <returns>String representation.</returns> public string ToString(ApparentPowerUnit unit, [CanBeNull] string cultureName) { return(ToString(unit, cultureName, 2)); }
public static string GetAbbreviation( ApparentPowerUnit unit, #if WINDOWS_UWP [CanBeNull] string cultureName)