static Compressibility() { BaseDimensions = new BaseDimensions(1, -1, 2, 0, 0, 0, 0); BaseUnit = CompressibilityUnit.InversePascal; MaxValue = new Compressibility(double.MaxValue, BaseUnit); MinValue = new Compressibility(double.MinValue, BaseUnit); QuantityType = QuantityType.Compressibility; Units = Enum.GetValues(typeof(CompressibilityUnit)).Cast <CompressibilityUnit>().Except(new CompressibilityUnit[] { CompressibilityUnit.Undefined }).ToArray(); Zero = new Compressibility(0, BaseUnit); Info = new QuantityInfo <CompressibilityUnit>("Compressibility", new UnitInfo <CompressibilityUnit>[] { new UnitInfo <CompressibilityUnit>(CompressibilityUnit.InverseAtmosphere, "InverseAtmospheres", BaseUnits.Undefined), new UnitInfo <CompressibilityUnit>(CompressibilityUnit.InverseBar, "InverseBars", BaseUnits.Undefined), new UnitInfo <CompressibilityUnit>(CompressibilityUnit.InverseKilopascal, "InverseKilopascals", BaseUnits.Undefined), new UnitInfo <CompressibilityUnit>(CompressibilityUnit.InverseMegapascal, "InverseMegapascals", BaseUnits.Undefined), new UnitInfo <CompressibilityUnit>(CompressibilityUnit.InverseMillibar, "InverseMillibars", BaseUnits.Undefined), new UnitInfo <CompressibilityUnit>(CompressibilityUnit.InversePascal, "InversePascals", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second)), new UnitInfo <CompressibilityUnit>(CompressibilityUnit.InversePoundForcePerSquareInch, "InversePoundsForcePerSquareInch", BaseUnits.Undefined), }, BaseUnit, Zero, BaseDimensions, QuantityType.Compressibility); DefaultConversionFunctions = new UnitConverter(); RegisterDefaultConversions(DefaultConversionFunctions); }
public static bool TryParse(string?str, IFormatProvider?provider, out Compressibility result) { return(QuantityParser.Default.TryParse <Compressibility, CompressibilityUnit>( str, provider, From, out result)); }
static Compressibility() { BaseDimensions = new BaseDimensions(1, -1, 2, 0, 0, 0, 0); BaseUnit = CompressibilityUnit.InversePascal; MaxValue = new Compressibility(double.MaxValue, BaseUnit); MinValue = new Compressibility(double.MinValue, BaseUnit); QuantityType = QuantityType.Compressibility; Units = Enum.GetValues(typeof(CompressibilityUnit)).Cast <CompressibilityUnit>().Except(new CompressibilityUnit[] { CompressibilityUnit.Undefined }).ToArray(); Zero = new Compressibility(0, BaseUnit); Info = new QuantityInfo(QuantityType.Compressibility, Units.Cast <Enum>().ToArray(), BaseUnit, Zero, BaseDimensions); }
/// <summary> /// <para> /// Compare equality to another Compressibility within the given absolute or relative tolerance. /// </para> /// <para> /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and /// <paramref name="other"/> as a percentage of this quantity's value. <paramref name="other"/> will be converted into /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of /// this quantity's value to be considered equal. /// <example> /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). /// <code> /// var a = Length.FromMeters(2.0); /// var b = Length.FromInches(50.0); /// a.Equals(b, 0.01, ComparisonType.Relative); /// </code> /// </example> /// </para> /// <para> /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and /// <paramref name="other"/> as a fixed number in this quantity's unit. <paramref name="other"/> will be converted into /// this quantity's unit for comparison. /// <example> /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). /// <code> /// var a = Length.FromMeters(2.0); /// var b = Length.FromInches(50.0); /// a.Equals(b, 0.01, ComparisonType.Absolute); /// </code> /// </example> /// </para> /// <para> /// Note that it is advised against specifying zero difference, due to the nature /// of floating point operations and using System.Double internally. /// </para> /// </summary> /// <param name="other">The other quantity to compare to.</param> /// <param name="tolerance">The absolute or relative tolerance value. Must be greater than or equal to 0.</param> /// <param name="comparisonType">The comparison type: either relative or absolute.</param> /// <returns>True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.</returns> public bool Equals(Compressibility other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) { throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); } double thisValue = (double)this.Value; double otherValueInThisUnits = other.As(this.Unit); return(UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType)); }
public bool Equals(Compressibility other) { return(_value.Equals(other.AsBaseNumericType(this.Unit))); }
// Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods internal int CompareTo(Compressibility other) { return(_value.CompareTo(other.AsBaseNumericType(this.Unit))); }
/// <summary> /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". /// </summary> /// <param name="str">String to parse. Typically in the form: {number} {unit}</param> /// <param name="result">Resulting unit quantity if successful.</param> /// <returns>True if successful, otherwise false.</returns> /// <example> /// Length.Parse("5.5 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 TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Compressibility result) { IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); return(QuantityParser.Default.TryParse <Compressibility, CompressibilityUnit>( str, provider, From, out result)); }
/// <summary> /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". /// </summary> /// <param name="str">String to parse. Typically in the form: {number} {unit}</param> /// <param name="result">Resulting unit quantity if successful.</param> /// <example> /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// </example> public static bool TryParse([CanBeNull] string str, out Compressibility result) { return(TryParse(str, null, out result)); }
public bool Equals(Compressibility other) { return(_value.Equals(other.GetValueAs(this.Unit))); }
public int CompareTo(Compressibility other) { return(_value.CompareTo(other.GetValueAs(this.Unit))); }