diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index cf48ef7b4d..9ccc1e97c4 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -262,11 +262,11 @@ private void GenerateProperties() public {_valueType} Value => _value; "); - // Need to provide explicit interface implementation for decimal quantities like Information - if (_quantity.ValueType != "double") - Writer.WL(@" - double IQuantity.Value => (double) _value; + Writer.WL(@" + /// + QuantityValue IQuantity.Value => _value; "); + // Need to provide explicit interface implementation for decimal quantities like Information if (_quantity.ValueType == "decimal") Writer.WL(@" /// @@ -306,11 +306,11 @@ private void GenerateConversionProperties() Writer.WL($@" /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// "); Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit)); Writer.WL($@" - public double {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); + public {_quantity.ValueType} {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); "); } @@ -651,7 +651,7 @@ private void GenerateArithmeticOperators() }} /// Get ratio value from dividing by . - public static double operator /({_quantity.Name} left, {_quantity.Name} right) + public static {_quantity.ValueType} operator /({_quantity.Name} left, {_quantity.Name} right) {{ return left.{_baseUnit.PluralName} / right.{_baseUnit.PluralName}; }} @@ -806,13 +806,13 @@ public int CompareTo({_quantity.Name} other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals({_quantity.Name} other, double tolerance, ComparisonType comparisonType) + public bool Equals({_quantity.Name} other, {_quantity.ValueType} 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); + {_quantity.ValueType} thisValue = this.Value; + {_quantity.ValueType} otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); }} @@ -839,17 +839,30 @@ private void GenerateConversionMethods() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As({_unitEnumName} unit) + public {_quantity.ValueType} As({_unitEnumName} unit) {{ if (Unit == unit) - return Convert.ToDouble(Value); + return Value; + + return GetValueAs(unit); + }} +"); - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + if (_quantity.ValueType == "decimal") + { + Writer.WL($@" + + double IQuantity<{_unitEnumName}>.As({_unitEnumName} unit) + {{ + return (double)As(unit); }} +"); + } + + Writer.WL($@" /// - public double As(UnitSystem unitSystem) + public {_quantity.ValueType} As(UnitSystem unitSystem) {{ if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -862,14 +875,27 @@ public double As(UnitSystem unitSystem) return As(firstUnitInfo.Value); }} +"); + + if (_quantity.ValueType == "decimal") + { + Writer.WL($@" + /// + double IQuantity.As(UnitSystem unitSystem) + {{ + return (double)As(unitSystem); + }} +"); + } + Writer.WL($@" /// double IQuantity.As(Enum unit) {{ - if (!(unit is {_unitEnumName} unitAs{_unitEnumName})) + if (!(unit is {_unitEnumName} typedUnit)) throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit)); - return As(unitAs{_unitEnumName}); + return (double)As(typedUnit); }} /// @@ -916,10 +942,10 @@ double IQuantity.As(Enum unit) /// IQuantity IQuantity.ToUnit(Enum unit) {{ - if (!(unit is {_unitEnumName} unitAs{_unitEnumName})) + if (!(unit is {_unitEnumName} typedUnit)) throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit)); - return ToUnit(unitAs{_unitEnumName}, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); }} /// diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index b9a4f2db68..ee1518171a 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -102,7 +102,7 @@ public abstract partial class {_quantity.Name}TestsBase : QuantityTestsBase continue; Writer.WL($@" - protected abstract double {unit.PluralName}InOne{_baseUnit.SingularName} {{ get; }}"); + protected abstract {_quantity.ValueType} {unit.PluralName}InOne{_baseUnit.SingularName} {{ get; }}"); } Writer.WL(""); @@ -114,12 +114,12 @@ public abstract partial class {_quantity.Name}TestsBase : QuantityTestsBase continue; Writer.WL($@" - protected virtual double {unit.PluralName}Tolerance {{ get {{ return 1e-5; }} }}"); + protected virtual {_quantity.ValueType} {unit.PluralName}Tolerance {{ get {{ return { (_quantity.ValueType == "decimal" ? "1e-9m" : "1e-5") }; }} }}"); } Writer.WL($@" // ReSharper restore VirtualMemberNeverOverriden.Global - protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor({_unitEnumName} unit) + protected ({_quantity.ValueType} UnitsInBaseUnit, {_quantity.ValueType} Tolerence) GetConversionFactor({_unitEnumName} unit) {{ return unit switch {{"); @@ -355,7 +355,7 @@ public void ToUnit({_unitEnumName} unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); }} diff --git a/Common/UnitDefinitions/Power.json b/Common/UnitDefinitions/Power.json index 89f98458eb..ce491fa507 100644 --- a/Common/UnitDefinitions/Power.json +++ b/Common/UnitDefinitions/Power.json @@ -85,8 +85,8 @@ { "SingularName": "BritishThermalUnitPerHour", "PluralName": "BritishThermalUnitsPerHour", - "FromUnitToBaseFunc": "{x} * 0.293071m", - "FromBaseToUnitFunc": "{x} / 0.293071m", + "FromUnitToBaseFunc": "{x} * 0.29307107017m", + "FromBaseToUnitFunc": "{x} / 0.29307107017m", "Prefixes": [ "Kilo", "Mega" ], "Localization": [ { diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs index 5c25292799..e10cb3d208 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs @@ -410,7 +410,7 @@ private double GetValueInBaseUnit() return Unit switch { PowerUnit.BoilerHorsepower => _value * 9812.5d, - PowerUnit.BritishThermalUnitPerHour => _value * 0.293071d, + PowerUnit.BritishThermalUnitPerHour => _value * 0.29307107017d, PowerUnit.Decawatt => (_value) * 1e1d, PowerUnit.Deciwatt => (_value) * 1e-1d, PowerUnit.ElectricalHorsepower => _value * 746d, @@ -419,11 +419,11 @@ private double GetValueInBaseUnit() PowerUnit.Gigawatt => (_value) * 1e9d, PowerUnit.HydraulicHorsepower => _value * 745.69988145d, PowerUnit.JoulePerHour => _value / 3600d, - PowerUnit.KilobritishThermalUnitPerHour => (_value * 0.293071d) * 1e3d, + PowerUnit.KilobritishThermalUnitPerHour => (_value * 0.29307107017d) * 1e3d, PowerUnit.KilojoulePerHour => (_value / 3600d) * 1e3d, PowerUnit.Kilowatt => (_value) * 1e3d, PowerUnit.MechanicalHorsepower => _value * 745.69d, - PowerUnit.MegabritishThermalUnitPerHour => (_value * 0.293071d) * 1e6d, + PowerUnit.MegabritishThermalUnitPerHour => (_value * 0.29307107017d) * 1e6d, PowerUnit.MegajoulePerHour => (_value / 3600d) * 1e6d, PowerUnit.Megawatt => (_value) * 1e6d, PowerUnit.MetricHorsepower => _value * 735.49875d, @@ -449,7 +449,7 @@ private double GetValueAs(PowerUnit unit) return unit switch { PowerUnit.BoilerHorsepower => baseUnitValue / 9812.5d, - PowerUnit.BritishThermalUnitPerHour => baseUnitValue / 0.293071d, + PowerUnit.BritishThermalUnitPerHour => baseUnitValue / 0.29307107017d, PowerUnit.Decawatt => (baseUnitValue) / 1e1d, PowerUnit.Deciwatt => (baseUnitValue) / 1e-1d, PowerUnit.ElectricalHorsepower => baseUnitValue / 746d, @@ -458,11 +458,11 @@ private double GetValueAs(PowerUnit unit) PowerUnit.Gigawatt => (baseUnitValue) / 1e9d, PowerUnit.HydraulicHorsepower => baseUnitValue / 745.69988145d, PowerUnit.JoulePerHour => baseUnitValue * 3600d, - PowerUnit.KilobritishThermalUnitPerHour => (baseUnitValue / 0.293071d) / 1e3d, + PowerUnit.KilobritishThermalUnitPerHour => (baseUnitValue / 0.29307107017d) / 1e3d, PowerUnit.KilojoulePerHour => (baseUnitValue * 3600d) / 1e3d, PowerUnit.Kilowatt => (baseUnitValue) / 1e3d, PowerUnit.MechanicalHorsepower => baseUnitValue / 745.69d, - PowerUnit.MegabritishThermalUnitPerHour => (baseUnitValue / 0.293071d) / 1e6d, + PowerUnit.MegabritishThermalUnitPerHour => (baseUnitValue / 0.29307107017d) / 1e6d, PowerUnit.MegajoulePerHour => (baseUnitValue * 3600d) / 1e6d, PowerUnit.Megawatt => (baseUnitValue) / 1e6d, PowerUnit.MetricHorsepower => baseUnitValue / 735.49875d, diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs index 9aa3d59239..76e82be109 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs @@ -54,7 +54,7 @@ public void UnitsNetBaseJsonConverter_ConvertValueUnit_works_as_expected() Assert.NotNull(result); Assert.IsType(result); - Assert.True(Power.FromWatts(10.2365m).Equals((Power)result, 1E-5, ComparisonType.Absolute)); + Assert.True(Power.FromWatts(10.2365m).Equals((Power)result, 1E-5m, ComparisonType.Absolute)); } diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs index f8053607da..bbe5522852 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs @@ -117,7 +117,7 @@ public void UnitsNetIComparableJsonConverter_ReadJson_works_as_expected() Assert.NotNull(result); Assert.IsType(result); - Assert.Equal(120D, ((Power)result).Watts); + Assert.Equal(120M, ((Power)result).Watts); } } } diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs index ea87af940d..8ed7de7c29 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs @@ -135,7 +135,7 @@ public void UnitsNetIQuantityJsonConverter_ReadJson_works_as_expected() Assert.NotNull(result); Assert.IsType(result); - Assert.Equal(10.3654D, ((Power)result).Watts); + Assert.Equal(10.3654M, ((Power)result).Watts); } } } diff --git a/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs b/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs index b7a150b944..2b89bee8df 100644 --- a/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs +++ b/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs @@ -85,7 +85,7 @@ public override void WriteJson(JsonWriter writer, IQuantity? quantity, JsonSeria } else { - writer.WriteValue(quantity.Value); + writer.WriteValue((double)quantity.Value); } // write the 'Unit' abbreviation diff --git a/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs b/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs index 2e804182c7..3373b27b26 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs +++ b/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs @@ -186,13 +186,14 @@ protected ValueUnit ConvertIQuantity(IQuantity quantity) return new ExtendedValueUnit { Unit = $"{quantity.QuantityInfo.UnitType.Name}.{quantity.Unit}", - Value = quantity.Value, + // The type of "Value" is still double + Value = (double)quantity.Value, ValueString = d.Value.ToString(CultureInfo.InvariantCulture), ValueType = "decimal" }; } - return new ValueUnit {Value = quantity.Value, Unit = $"{quantity.QuantityInfo.UnitType.Name}.{quantity.Unit}"}; + return new ValueUnit {Value = (double)quantity.Value, Unit = $"{quantity.QuantityInfo.UnitType.Name}.{quantity.Unit}"}; } /// diff --git a/UnitsNet.Tests/AssertEx.cs b/UnitsNet.Tests/AssertEx.cs index d052adfeec..229e4324e7 100644 --- a/UnitsNet.Tests/AssertEx.cs +++ b/UnitsNet.Tests/AssertEx.cs @@ -25,5 +25,23 @@ public static void EqualTolerance(double expected, double actual, double toleran Assert.True( areEqual, $"Values are not equal within absolute tolerance: {tolerance}\nExpected: {expected}\nActual: {actual}\nDiff: {actual - expected:e}" ); } } + + public static void EqualTolerance(decimal expected, decimal actual, decimal tolerance, ComparisonType comparisonType = ComparisonType.Relative) + { + if (comparisonType == ComparisonType.Relative) + { + bool areEqual = Comparison.EqualsRelative(expected, actual, tolerance); + + decimal difference = Math.Abs(expected - actual); + decimal relativeDifference = difference / expected; + + Assert.True(areEqual, $"Values are not equal within relative tolerance: {tolerance:P4}\nExpected: {expected}\nActual: {actual}\nDiff: {relativeDifference:P4}"); + } + else if (comparisonType == ComparisonType.Absolute) + { + bool areEqual = Comparison.EqualsAbsolute(expected, actual, tolerance); + Assert.True(areEqual, $"Values are not equal within absolute tolerance: {tolerance}\nExpected: {expected}\nActual: {actual}\nDiff: {actual - expected:e}"); + } + } } } diff --git a/UnitsNet.Tests/CustomCode/BitRateTests.cs b/UnitsNet.Tests/CustomCode/BitRateTests.cs index 2afe11ae27..5e49dc8ad3 100644 --- a/UnitsNet.Tests/CustomCode/BitRateTests.cs +++ b/UnitsNet.Tests/CustomCode/BitRateTests.cs @@ -29,37 +29,37 @@ public class BitRateTests : BitRateTestsBase { protected override bool SupportsSIUnitSystem => false; - protected override double BitsPerSecondInOneBitPerSecond => 1d; - protected override double BytesPerSecondInOneBitPerSecond => 1.25E-1d; + protected override decimal BitsPerSecondInOneBitPerSecond => 1m; + protected override decimal BytesPerSecondInOneBitPerSecond => 1.25E-1m; - protected override double KilobitsPerSecondInOneBitPerSecond => 1E-3d; - protected override double KilobytesPerSecondInOneBitPerSecond => 1.25E-4d; - protected override double KibibitsPerSecondInOneBitPerSecond => 0.0009765625d; - protected override double KibibytesPerSecondInOneBitPerSecond => 0.0001220703125d; + protected override decimal KilobitsPerSecondInOneBitPerSecond => 1E-3m; + protected override decimal KilobytesPerSecondInOneBitPerSecond => 1.25E-4m; + protected override decimal KibibitsPerSecondInOneBitPerSecond => 0.0009765625m; + protected override decimal KibibytesPerSecondInOneBitPerSecond => 0.0001220703125m; - protected override double MegabitsPerSecondInOneBitPerSecond => 1E-6d; - protected override double MegabytesPerSecondInOneBitPerSecond => 1.25E-07d; - protected override double MebibitsPerSecondInOneBitPerSecond => 9.5367431640625E-07d; - protected override double MebibytesPerSecondInOneBitPerSecond => 1.19209289550781E-07d; + protected override decimal MegabitsPerSecondInOneBitPerSecond => 1E-6m; + protected override decimal MegabytesPerSecondInOneBitPerSecond => 1.25E-07m; + protected override decimal MebibitsPerSecondInOneBitPerSecond => 9.5367431640625E-07m; + protected override decimal MebibytesPerSecondInOneBitPerSecond => 1.19209289550781E-07m; - protected override double GigabitsPerSecondInOneBitPerSecond => 1E-9d; - protected override double GigabytesPerSecondInOneBitPerSecond => 1.25E-10d; - protected override double GibibitsPerSecondInOneBitPerSecond => 9.31322574615479E-10d; - protected override double GibibytesPerSecondInOneBitPerSecond => 1.16415321826935E-10d; + protected override decimal GigabitsPerSecondInOneBitPerSecond => 1E-9m; + protected override decimal GigabytesPerSecondInOneBitPerSecond => 1.25E-10m; + protected override decimal GibibitsPerSecondInOneBitPerSecond => 9.31322574615479E-10m; + protected override decimal GibibytesPerSecondInOneBitPerSecond => 1.16415321826935E-10m; - protected override double TerabitsPerSecondInOneBitPerSecond => 1E-12d; - protected override double TerabytesPerSecondInOneBitPerSecond => 1.25E-13d; - protected override double TebibitsPerSecondInOneBitPerSecond => 9.09494701772928E-13d; - protected override double TebibytesPerSecondInOneBitPerSecond => 1.13686837721616E-13d; + protected override decimal TerabitsPerSecondInOneBitPerSecond => 1E-12m; + protected override decimal TerabytesPerSecondInOneBitPerSecond => 1.25E-13m; + protected override decimal TebibitsPerSecondInOneBitPerSecond => 9.09494701772928E-13m; + protected override decimal TebibytesPerSecondInOneBitPerSecond => 1.13686837721616E-13m; - protected override double PetabitsPerSecondInOneBitPerSecond => 1E-15d; - protected override double PetabytesPerSecondInOneBitPerSecond => 1.25E-16d; - protected override double PebibitsPerSecondInOneBitPerSecond => 8.88178419700125E-16d; - protected override double PebibytesPerSecondInOneBitPerSecond => 1.11022302462516E-16d; + protected override decimal PetabitsPerSecondInOneBitPerSecond => 1E-15m; + protected override decimal PetabytesPerSecondInOneBitPerSecond => 1.25E-16m; + protected override decimal PebibitsPerSecondInOneBitPerSecond => 8.88178419700125E-16m; + protected override decimal PebibytesPerSecondInOneBitPerSecond => 1.11022302462516E-16m; - protected override double ExabitsPerSecondInOneBitPerSecond => 1E-18d; - protected override double ExabytesPerSecondInOneBitPerSecond => 1.25E-19d; - protected override double ExbibitsPerSecondInOneBitPerSecond => 8.67361738E-19d; - protected override double ExbibytesPerSecondInOneBitPerSecond => 1.0842021724855E-19d; + protected override decimal ExabitsPerSecondInOneBitPerSecond => 1E-18m; + protected override decimal ExabytesPerSecondInOneBitPerSecond => 1.25E-19m; + protected override decimal ExbibitsPerSecondInOneBitPerSecond => 8.67361738E-19m; + protected override decimal ExbibytesPerSecondInOneBitPerSecond => 1.0842021724855E-19m; } } diff --git a/UnitsNet.Tests/CustomCode/InformationTests.cs b/UnitsNet.Tests/CustomCode/InformationTests.cs index dc0dbfd879..4e2b1fa474 100644 --- a/UnitsNet.Tests/CustomCode/InformationTests.cs +++ b/UnitsNet.Tests/CustomCode/InformationTests.cs @@ -9,57 +9,57 @@ namespace UnitsNet.Tests.CustomCode public class InformationTests : InformationTestsBase { protected override bool SupportsSIUnitSystem => false; - protected override double BitsInOneBit => 1d; + protected override decimal BitsInOneBit => 1m; - protected override double BytesInOneBit => 0.125d; + protected override decimal BytesInOneBit => 0.125m; - protected override double ExabitsInOneBit => 1e-18d; + protected override decimal ExabitsInOneBit => 1e-18m; - protected override double ExabytesInOneBit => 0.125d*1e-18d; + protected override decimal ExabytesInOneBit => 0.125m*1e-18m; - protected override double ExbibitsInOneBit => 1d/Math.Pow(1024, 6); + protected override decimal ExbibitsInOneBit => 1m/(decimal)Math.Pow(1024, 6); - protected override double ExbibytesInOneBit => 1/8d/Math.Pow(1024, 6); + protected override decimal ExbibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 6); - protected override double GibibitsInOneBit => 1d/Math.Pow(1024, 3); + protected override decimal GibibitsInOneBit => 1m/(decimal)Math.Pow(1024, 3); - protected override double GibibytesInOneBit => 1d/8/Math.Pow(1024, 3); + protected override decimal GibibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 3); - protected override double GigabitsInOneBit => 1e-9d; + protected override decimal GigabitsInOneBit => 1e-9m; - protected override double GigabytesInOneBit => 0.125d*1e-9d; + protected override decimal GigabytesInOneBit => 0.125m*1e-9m; - protected override double KibibitsInOneBit => 1d/1024d; + protected override decimal KibibitsInOneBit => 1m/1024m; - protected override double KibibytesInOneBit => 1d/8/1024d; + protected override decimal KibibytesInOneBit => 1m/8/1024m; - protected override double KilobitsInOneBit => 0.001d; + protected override decimal KilobitsInOneBit => 0.001m; - protected override double KilobytesInOneBit => 0.000125d; + protected override decimal KilobytesInOneBit => 0.000125m; - protected override double MebibitsInOneBit => 1d/Math.Pow(1024, 2); + protected override decimal MebibitsInOneBit => 1m/(decimal)Math.Pow(1024, 2); - protected override double MebibytesInOneBit => 1d/8/Math.Pow(1024, 2); + protected override decimal MebibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 2); - protected override double MegabitsInOneBit => 1e-6d; + protected override decimal MegabitsInOneBit => 1e-6m; - protected override double MegabytesInOneBit => 0.125d*1e-6d; + protected override decimal MegabytesInOneBit => 0.125m*1e-6m; - protected override double PebibitsInOneBit => 1d/Math.Pow(1024, 5); + protected override decimal PebibitsInOneBit => 1m/(decimal)Math.Pow(1024, 5); - protected override double PebibytesInOneBit => 1d/8/Math.Pow(1024, 5); + protected override decimal PebibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 5); - protected override double PetabitsInOneBit => 1e-15d; + protected override decimal PetabitsInOneBit => 1e-15m; - protected override double PetabytesInOneBit => 0.125d*1e-15d; + protected override decimal PetabytesInOneBit => 0.125m*1e-15m; - protected override double TebibitsInOneBit => 1d/Math.Pow(1024, 4); + protected override decimal TebibitsInOneBit => 1m/(decimal)Math.Pow(1024, 4); - protected override double TebibytesInOneBit => 1d/8/Math.Pow(1024, 4); + protected override decimal TebibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 4); - protected override double TerabitsInOneBit => 1e-12d; + protected override decimal TerabitsInOneBit => 1e-12m; - protected override double TerabytesInOneBit => 0.125d*1e-12d; + protected override decimal TerabytesInOneBit => 0.125m*1e-12m; [Fact] public void OneKBHas1000Bytes() diff --git a/UnitsNet.Tests/CustomCode/MassFlowTests.cs b/UnitsNet.Tests/CustomCode/MassFlowTests.cs index 9d7cb97f2d..711f82b28d 100644 --- a/UnitsNet.Tests/CustomCode/MassFlowTests.cs +++ b/UnitsNet.Tests/CustomCode/MassFlowTests.cs @@ -108,7 +108,7 @@ public void TimeSpanTimesMassFlowEqualsMass() public void MassFlowDividedByBrakeSpecificFuelConsumptionEqualsPower() { Power power = MassFlow.FromTonnesPerDay(20) / BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(180.0); - Assert.Equal(20.0 / 24.0 * 1e6 / 180.0, power.Kilowatts); + AssertEx.EqualTolerance(20.0m / 24.0m * 1e6m / 180.0m, power.Kilowatts, 1E-11m); } [Fact] diff --git a/UnitsNet.Tests/CustomCode/PowerRatioTests.cs b/UnitsNet.Tests/CustomCode/PowerRatioTests.cs index e6820ea023..7e149043e6 100644 --- a/UnitsNet.Tests/CustomCode/PowerRatioTests.cs +++ b/UnitsNet.Tests/CustomCode/PowerRatioTests.cs @@ -46,6 +46,7 @@ public void ExpectPowerConvertedCorrectly(double power, double expected) } [Theory] + // Note: Attribute arguments cannot be of type decimal. [InlineData(-20, 0.01)] [InlineData(-10, 0.1)] [InlineData(0, 1)] @@ -54,8 +55,8 @@ public void ExpectPowerConvertedCorrectly(double power, double expected) public void ExpectPowerRatioConvertedCorrectly(double powerRatio, double expected) { PowerRatio pr = PowerRatio.FromDecibelWatts(powerRatio); - double actual = pr.ToPower().Watts; - Assert.Equal(expected, actual); + decimal actual = pr.ToPower().Watts; + Assert.Equal((decimal)expected, actual); } // http://www.maximintegrated.com/en/app-notes/index.mvp/id/808 diff --git a/UnitsNet.Tests/CustomCode/PowerTests.cs b/UnitsNet.Tests/CustomCode/PowerTests.cs index b965e8fa83..8161a50849 100644 --- a/UnitsNet.Tests/CustomCode/PowerTests.cs +++ b/UnitsNet.Tests/CustomCode/PowerTests.cs @@ -9,57 +9,57 @@ namespace UnitsNet.Tests.CustomCode public class PowerTests : PowerTestsBase { protected override bool SupportsSIUnitSystem => false; - protected override double FemtowattsInOneWatt => 1e15; + protected override decimal FemtowattsInOneWatt => 1e15m; - protected override double GigajoulesPerHourInOneWatt => 3600e-9; + protected override decimal GigajoulesPerHourInOneWatt => 3600e-9m; - protected override double PicowattsInOneWatt => 1e12; + protected override decimal PicowattsInOneWatt => 1e12m; - protected override double NanowattsInOneWatt => 1e9; + protected override decimal NanowattsInOneWatt => 1e9m; - protected override double MicrowattsInOneWatt => 1e6; + protected override decimal MicrowattsInOneWatt => 1e6m; - protected override double MillijoulesPerHourInOneWatt => 3600e3; + protected override decimal MillijoulesPerHourInOneWatt => 3600e3m; - protected override double MilliwattsInOneWatt => 1e3; + protected override decimal MilliwattsInOneWatt => 1e3m; - protected override double DeciwattsInOneWatt => 1e1; + protected override decimal DeciwattsInOneWatt => 1e1m; - protected override double WattsInOneWatt => 1; + protected override decimal WattsInOneWatt => 1; - protected override double DecawattsInOneWatt => 1e-1; + protected override decimal DecawattsInOneWatt => 1e-1m; - protected override double KilojoulesPerHourInOneWatt => 3600e-3; + protected override decimal KilojoulesPerHourInOneWatt => 3600e-3m; - protected override double KilowattsInOneWatt => 1e-3; + protected override decimal KilowattsInOneWatt => 1e-3m; - protected override double MegajoulesPerHourInOneWatt => 3600e-6; + protected override decimal MegajoulesPerHourInOneWatt => 3600e-6m; - protected override double MegawattsInOneWatt => 1e-6; + protected override decimal MegawattsInOneWatt => 1e-6m; - protected override double GigawattsInOneWatt => 1e-9; + protected override decimal GigawattsInOneWatt => 1e-9m; - protected override double TerawattsInOneWatt => 1e-12; + protected override decimal TerawattsInOneWatt => 1e-12m; - protected override double PetawattsInOneWatt => 1e-15; + protected override decimal PetawattsInOneWatt => 1e-15m; - protected override double JoulesPerHourInOneWatt => 3600; + protected override decimal JoulesPerHourInOneWatt => 3600; - protected override double KilobritishThermalUnitsPerHourInOneWatt => 3.412141633e-3; + protected override decimal KilobritishThermalUnitsPerHourInOneWatt => 3.412141633e-3m; - protected override double MegabritishThermalUnitsPerHourInOneWatt => 3.412141633e-6; + protected override decimal BoilerHorsepowerInOneWatt => 1.0191082802547770700636942675159e-4m; - protected override double BoilerHorsepowerInOneWatt => 1.0191082802547770700636942675159e-4; + protected override decimal MegabritishThermalUnitsPerHourInOneWatt => 3.412141633e-6m; - protected override double BritishThermalUnitsPerHourInOneWatt => 3.412141633; + protected override decimal BritishThermalUnitsPerHourInOneWatt => 3.412141633m; - protected override double ElectricalHorsepowerInOneWatt => 0.00134048257372654155495978552279; + protected override decimal ElectricalHorsepowerInOneWatt => 0.00134048257372654155495978552279m; - protected override double HydraulicHorsepowerInOneWatt => 0.00134102207184949258114167291719; + protected override decimal HydraulicHorsepowerInOneWatt => 0.00134102207184949258114167291719m; - protected override double MechanicalHorsepowerInOneWatt => 0.00134103984229371454625916935992; + protected override decimal MechanicalHorsepowerInOneWatt => 0.00134103984229371454625916935992m; - protected override double MetricHorsepowerInOneWatt => 0.00135962161730390432342679032425; + protected override decimal MetricHorsepowerInOneWatt => 0.00135962161730390432342679032425m; [Fact] public void DurationTimesPowerEqualsEnergy() diff --git a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs index 15fb16bb45..ae3ed730c5 100644 --- a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs +++ b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs @@ -70,7 +70,7 @@ public void DoubleDividedBySpecificEnergyEqualsBrakeSpecificFuelConsumption() public void SpecificEnergyTimesMassFlowEqualsPower() { Power power = SpecificEnergy.FromJoulesPerKilogram(10.0) * MassFlow.FromKilogramsPerSecond(20.0); - Assert.Equal(200d, power.Watts); + Assert.Equal(200m, power.Watts); } [Fact] diff --git a/UnitsNet.Tests/CustomQuantities/HowMuch.cs b/UnitsNet.Tests/CustomQuantities/HowMuch.cs index cafdfc75ae..908caecfa9 100644 --- a/UnitsNet.Tests/CustomQuantities/HowMuch.cs +++ b/UnitsNet.Tests/CustomQuantities/HowMuch.cs @@ -17,7 +17,7 @@ public HowMuch(double value, HowMuchUnit unit) Enum IQuantity.Unit => Unit; public HowMuchUnit Unit { get; } - public double Value { get; } + public QuantityValue Value { get; } #region IQuantity diff --git a/UnitsNet.Tests/DecimalOverloadTests.cs b/UnitsNet.Tests/DecimalOverloadTests.cs index 841c9b162b..6b9842d0aa 100644 --- a/UnitsNet.Tests/DecimalOverloadTests.cs +++ b/UnitsNet.Tests/DecimalOverloadTests.cs @@ -18,7 +18,7 @@ public static void CreatingQuantityWithDoubleBackingFieldFromDecimalReturnsCorre public static void CreatingQuantityWithDecimalBackingFieldFromDecimalReturnsCorrectValue() { Power power = Power.FromWatts(1m); - Assert.Equal(1.0, power.Watts); + Assert.Equal(1.0m, power.Watts); } } } diff --git a/UnitsNet.Tests/DummyIQuantity.cs b/UnitsNet.Tests/DummyIQuantity.cs index cda0f506b1..bd9f57c2e7 100644 --- a/UnitsNet.Tests/DummyIQuantity.cs +++ b/UnitsNet.Tests/DummyIQuantity.cs @@ -11,7 +11,7 @@ internal class DummyIQuantity : IQuantity public Enum Unit => throw new NotImplementedException(); - public double Value => throw new NotImplementedException(); + public QuantityValue Value => throw new NotImplementedException(); public double As(Enum unit ) => throw new NotImplementedException(); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index f70180cba6..8eef770a85 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -997,7 +997,7 @@ public void ToUnit(AccelerationUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index 52cc5fa708..b3d7ce944d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -673,7 +673,7 @@ public void ToUnit(AmountOfSubstanceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index 53181b282b..cfb79be1be 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -321,7 +321,7 @@ public void ToUnit(AmplitudeRatioUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index b6f83dd254..fd9a87d4a0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -1257,7 +1257,7 @@ public void ToUnit(AngleUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs index e84c7b0aad..ed4d2b7afd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(ApparentEnergyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs index b650b9bcd9..809450eef1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs @@ -321,7 +321,7 @@ public void ToUnit(ApparentPowerUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index a9585c99c0..020dba5491 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(AreaDensityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index 2321a0aadf..f9518f3a59 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -533,7 +533,7 @@ public void ToUnit(AreaMomentOfInertiaUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index 39bffa73de..dae06225f0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -1287,7 +1287,7 @@ public void ToUnit(AreaUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index a26e942ea8..25db4265bb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -38,63 +38,63 @@ namespace UnitsNet.Tests // ReSharper disable once PartialTypeWithSinglePart public abstract partial class BitRateTestsBase : QuantityTestsBase { - protected abstract double BitsPerSecondInOneBitPerSecond { get; } - protected abstract double BytesPerSecondInOneBitPerSecond { get; } - protected abstract double ExabitsPerSecondInOneBitPerSecond { get; } - protected abstract double ExabytesPerSecondInOneBitPerSecond { get; } - protected abstract double ExbibitsPerSecondInOneBitPerSecond { get; } - protected abstract double ExbibytesPerSecondInOneBitPerSecond { get; } - protected abstract double GibibitsPerSecondInOneBitPerSecond { get; } - protected abstract double GibibytesPerSecondInOneBitPerSecond { get; } - protected abstract double GigabitsPerSecondInOneBitPerSecond { get; } - protected abstract double GigabytesPerSecondInOneBitPerSecond { get; } - protected abstract double KibibitsPerSecondInOneBitPerSecond { get; } - protected abstract double KibibytesPerSecondInOneBitPerSecond { get; } - protected abstract double KilobitsPerSecondInOneBitPerSecond { get; } - protected abstract double KilobytesPerSecondInOneBitPerSecond { get; } - protected abstract double MebibitsPerSecondInOneBitPerSecond { get; } - protected abstract double MebibytesPerSecondInOneBitPerSecond { get; } - protected abstract double MegabitsPerSecondInOneBitPerSecond { get; } - protected abstract double MegabytesPerSecondInOneBitPerSecond { get; } - protected abstract double PebibitsPerSecondInOneBitPerSecond { get; } - protected abstract double PebibytesPerSecondInOneBitPerSecond { get; } - protected abstract double PetabitsPerSecondInOneBitPerSecond { get; } - protected abstract double PetabytesPerSecondInOneBitPerSecond { get; } - protected abstract double TebibitsPerSecondInOneBitPerSecond { get; } - protected abstract double TebibytesPerSecondInOneBitPerSecond { get; } - protected abstract double TerabitsPerSecondInOneBitPerSecond { get; } - protected abstract double TerabytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal BitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal BytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal ExabitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal ExabytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal ExbibitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal ExbibytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal GibibitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal GibibytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal GigabitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal GigabytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal KibibitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal KibibytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal KilobitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal KilobytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal MebibitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal MebibytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal MegabitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal MegabytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal PebibitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal PebibytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal PetabitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal PetabytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal TebibitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal TebibytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal TerabitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal TerabytesPerSecondInOneBitPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double BytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double ExabitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double ExabytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double ExbibitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double ExbibytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double GibibitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double GibibytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double GigabitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double GigabytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double KibibitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double KibibytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double KilobitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double KilobytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double MebibitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double MebibytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double MegabitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double MegabytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double PebibitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double PebibytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double PetabitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double PetabytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double TebibitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double TebibytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double TerabitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double TerabytesPerSecondTolerance { get { return 1e-5; } } + protected virtual decimal BitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal BytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal ExabitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal ExabytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal ExbibitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal ExbibytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal GibibitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal GibibytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal GigabitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal GigabytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal KibibitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal KibibytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal KilobitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal KilobytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal MebibitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal MebibytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal MegabitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal MegabytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal PebibitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal PebibytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal PetabitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal PetabytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal TebibitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal TebibytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal TerabitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal TerabytesPerSecondTolerance { get { return 1e-9m; } } // ReSharper restore VirtualMemberNeverOverriden.Global - protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(BitRateUnit unit) + protected (decimal UnitsInBaseUnit, decimal Tolerence) GetConversionFactor(BitRateUnit unit) { return unit switch { @@ -1356,7 +1356,7 @@ public void ToUnit(BitRateUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index 6e1bc6b653..0eee9d0e6b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(BrakeSpecificFuelConsumptionUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs index e6d03a76dc..168173d243 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs @@ -401,7 +401,7 @@ public void ToUnit(CapacitanceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index 01b59f24d5..ee0a57c7d0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -359,7 +359,7 @@ public void ToUnit(CoefficientOfThermalExpansionUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs index aaf1331202..be84c575bb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs @@ -591,7 +591,7 @@ public void ToUnit(CompressibilityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index a37f498d85..3d84283c65 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -2015,7 +2015,7 @@ public void ToUnit(DensityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index 528fb07f8f..bfbec85a10 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -1735,7 +1735,7 @@ public void ToUnit(DurationUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index ee6a1a3d95..4297704cce 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -597,7 +597,7 @@ public void ToUnit(DynamicViscosityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index baf2955386..2f22972766 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -321,7 +321,7 @@ public void ToUnit(ElectricAdmittanceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index e5f237ac25..00774b96c6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(ElectricChargeDensityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index ffd6b25293..129bb0072d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -407,7 +407,7 @@ public void ToUnit(ElectricChargeUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index d7e199bded..27d6252268 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(ElectricConductanceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index 1819849908..657dbdb8ea 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(ElectricConductivityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index 8269cdcded..332b351ae0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(ElectricCurrentDensityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index 415f793b1c..5ebdc99523 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -321,7 +321,7 @@ public void ToUnit(ElectricCurrentGradientUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index 14be5a3b96..aecbe2fe1b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -435,7 +435,7 @@ public void ToUnit(ElectricCurrentUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index e75dc3285b..6cf1a78d49 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(ElectricFieldUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index b436a94c0d..f0e881a9e2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -321,7 +321,7 @@ public void ToUnit(ElectricInductanceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs index 54413cf013..d5cf5e1273 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs @@ -333,7 +333,7 @@ public void ToUnit(ElectricPotentialAcUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index 11f38843a9..834da37404 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -777,7 +777,7 @@ public void ToUnit(ElectricPotentialChangeRateUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs index d7b84a15dc..943eb1600b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs @@ -333,7 +333,7 @@ public void ToUnit(ElectricPotentialDcUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index 85c888287a..3b3c5e5b77 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -431,7 +431,7 @@ public void ToUnit(ElectricPotentialUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index 2f5ab2b600..e3e67b0899 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -367,7 +367,7 @@ public void ToUnit(ElectricResistanceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index 061188ed83..b79c19a2a9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -617,7 +617,7 @@ public void ToUnit(ElectricResistivityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index 50650f67de..ee35f72275 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(ElectricSurfaceChargeDensityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index 22b563d859..b7a30a0293 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -1891,7 +1891,7 @@ public void ToUnit(EnergyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index 06ae0fd4e5..3ee300f59c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -423,7 +423,7 @@ public void ToUnit(EntropyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index 6e46e12a28..56a7c50828 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -791,7 +791,7 @@ public void ToUnit(ForceChangeRateUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index c9979db3cf..2ba6c3674b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -1651,7 +1651,7 @@ public void ToUnit(ForcePerLengthUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index 28a015c7a7..4fba4daf36 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -1109,7 +1109,7 @@ public void ToUnit(ForceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index 6235036d30..dca8772335 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -727,7 +727,7 @@ public void ToUnit(FrequencyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index 267c73802f..3431afe279 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -321,7 +321,7 @@ public void ToUnit(FuelEfficiencyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index d894f51294..9af27ace3e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -821,7 +821,7 @@ public void ToUnit(HeatFluxUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index 0050e1ba0e..b3f9fd93b6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(HeatTransferCoefficientUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index d53ecaf4e4..d0b0c36d4a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -299,7 +299,7 @@ public void ToUnit(IlluminanceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index f48c5b7434..55b738ffdb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -38,63 +38,63 @@ namespace UnitsNet.Tests // ReSharper disable once PartialTypeWithSinglePart public abstract partial class InformationTestsBase : QuantityTestsBase { - protected abstract double BitsInOneBit { get; } - protected abstract double BytesInOneBit { get; } - protected abstract double ExabitsInOneBit { get; } - protected abstract double ExabytesInOneBit { get; } - protected abstract double ExbibitsInOneBit { get; } - protected abstract double ExbibytesInOneBit { get; } - protected abstract double GibibitsInOneBit { get; } - protected abstract double GibibytesInOneBit { get; } - protected abstract double GigabitsInOneBit { get; } - protected abstract double GigabytesInOneBit { get; } - protected abstract double KibibitsInOneBit { get; } - protected abstract double KibibytesInOneBit { get; } - protected abstract double KilobitsInOneBit { get; } - protected abstract double KilobytesInOneBit { get; } - protected abstract double MebibitsInOneBit { get; } - protected abstract double MebibytesInOneBit { get; } - protected abstract double MegabitsInOneBit { get; } - protected abstract double MegabytesInOneBit { get; } - protected abstract double PebibitsInOneBit { get; } - protected abstract double PebibytesInOneBit { get; } - protected abstract double PetabitsInOneBit { get; } - protected abstract double PetabytesInOneBit { get; } - protected abstract double TebibitsInOneBit { get; } - protected abstract double TebibytesInOneBit { get; } - protected abstract double TerabitsInOneBit { get; } - protected abstract double TerabytesInOneBit { get; } + protected abstract decimal BitsInOneBit { get; } + protected abstract decimal BytesInOneBit { get; } + protected abstract decimal ExabitsInOneBit { get; } + protected abstract decimal ExabytesInOneBit { get; } + protected abstract decimal ExbibitsInOneBit { get; } + protected abstract decimal ExbibytesInOneBit { get; } + protected abstract decimal GibibitsInOneBit { get; } + protected abstract decimal GibibytesInOneBit { get; } + protected abstract decimal GigabitsInOneBit { get; } + protected abstract decimal GigabytesInOneBit { get; } + protected abstract decimal KibibitsInOneBit { get; } + protected abstract decimal KibibytesInOneBit { get; } + protected abstract decimal KilobitsInOneBit { get; } + protected abstract decimal KilobytesInOneBit { get; } + protected abstract decimal MebibitsInOneBit { get; } + protected abstract decimal MebibytesInOneBit { get; } + protected abstract decimal MegabitsInOneBit { get; } + protected abstract decimal MegabytesInOneBit { get; } + protected abstract decimal PebibitsInOneBit { get; } + protected abstract decimal PebibytesInOneBit { get; } + protected abstract decimal PetabitsInOneBit { get; } + protected abstract decimal PetabytesInOneBit { get; } + protected abstract decimal TebibitsInOneBit { get; } + protected abstract decimal TebibytesInOneBit { get; } + protected abstract decimal TerabitsInOneBit { get; } + protected abstract decimal TerabytesInOneBit { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BitsTolerance { get { return 1e-5; } } - protected virtual double BytesTolerance { get { return 1e-5; } } - protected virtual double ExabitsTolerance { get { return 1e-5; } } - protected virtual double ExabytesTolerance { get { return 1e-5; } } - protected virtual double ExbibitsTolerance { get { return 1e-5; } } - protected virtual double ExbibytesTolerance { get { return 1e-5; } } - protected virtual double GibibitsTolerance { get { return 1e-5; } } - protected virtual double GibibytesTolerance { get { return 1e-5; } } - protected virtual double GigabitsTolerance { get { return 1e-5; } } - protected virtual double GigabytesTolerance { get { return 1e-5; } } - protected virtual double KibibitsTolerance { get { return 1e-5; } } - protected virtual double KibibytesTolerance { get { return 1e-5; } } - protected virtual double KilobitsTolerance { get { return 1e-5; } } - protected virtual double KilobytesTolerance { get { return 1e-5; } } - protected virtual double MebibitsTolerance { get { return 1e-5; } } - protected virtual double MebibytesTolerance { get { return 1e-5; } } - protected virtual double MegabitsTolerance { get { return 1e-5; } } - protected virtual double MegabytesTolerance { get { return 1e-5; } } - protected virtual double PebibitsTolerance { get { return 1e-5; } } - protected virtual double PebibytesTolerance { get { return 1e-5; } } - protected virtual double PetabitsTolerance { get { return 1e-5; } } - protected virtual double PetabytesTolerance { get { return 1e-5; } } - protected virtual double TebibitsTolerance { get { return 1e-5; } } - protected virtual double TebibytesTolerance { get { return 1e-5; } } - protected virtual double TerabitsTolerance { get { return 1e-5; } } - protected virtual double TerabytesTolerance { get { return 1e-5; } } + protected virtual decimal BitsTolerance { get { return 1e-9m; } } + protected virtual decimal BytesTolerance { get { return 1e-9m; } } + protected virtual decimal ExabitsTolerance { get { return 1e-9m; } } + protected virtual decimal ExabytesTolerance { get { return 1e-9m; } } + protected virtual decimal ExbibitsTolerance { get { return 1e-9m; } } + protected virtual decimal ExbibytesTolerance { get { return 1e-9m; } } + protected virtual decimal GibibitsTolerance { get { return 1e-9m; } } + protected virtual decimal GibibytesTolerance { get { return 1e-9m; } } + protected virtual decimal GigabitsTolerance { get { return 1e-9m; } } + protected virtual decimal GigabytesTolerance { get { return 1e-9m; } } + protected virtual decimal KibibitsTolerance { get { return 1e-9m; } } + protected virtual decimal KibibytesTolerance { get { return 1e-9m; } } + protected virtual decimal KilobitsTolerance { get { return 1e-9m; } } + protected virtual decimal KilobytesTolerance { get { return 1e-9m; } } + protected virtual decimal MebibitsTolerance { get { return 1e-9m; } } + protected virtual decimal MebibytesTolerance { get { return 1e-9m; } } + protected virtual decimal MegabitsTolerance { get { return 1e-9m; } } + protected virtual decimal MegabytesTolerance { get { return 1e-9m; } } + protected virtual decimal PebibitsTolerance { get { return 1e-9m; } } + protected virtual decimal PebibytesTolerance { get { return 1e-9m; } } + protected virtual decimal PetabitsTolerance { get { return 1e-9m; } } + protected virtual decimal PetabytesTolerance { get { return 1e-9m; } } + protected virtual decimal TebibitsTolerance { get { return 1e-9m; } } + protected virtual decimal TebibytesTolerance { get { return 1e-9m; } } + protected virtual decimal TerabitsTolerance { get { return 1e-9m; } } + protected virtual decimal TerabytesTolerance { get { return 1e-9m; } } // ReSharper restore VirtualMemberNeverOverriden.Global - protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(InformationUnit unit) + protected (decimal UnitsInBaseUnit, decimal Tolerence) GetConversionFactor(InformationUnit unit) { return unit switch { @@ -758,7 +758,7 @@ public void ToUnit(InformationUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index c0d10394f7..2921233abb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -617,7 +617,7 @@ public void ToUnit(IrradianceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index db173e10e8..02ee1ab34a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -423,7 +423,7 @@ public void ToUnit(IrradiationUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs index 4b8961c1d7..7daa612be5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs @@ -823,7 +823,7 @@ public void ToUnit(JerkUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index aad81609de..7ba8d63569 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -683,7 +683,7 @@ public void ToUnit(KinematicViscosityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs index 840ff97042..6809b4ae6d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(LapseRateUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index b063af3c1d..4ed2ddcaa6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -2213,7 +2213,7 @@ public void ToUnit(LengthUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index aa977dc3e4..7888edb6e0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -253,7 +253,7 @@ public void ToUnit(LevelUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index da6d13e43c..5b2b49380b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -661,7 +661,7 @@ public void ToUnit(LinearDensityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index 89f251de69..4c89b1be79 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -925,7 +925,7 @@ public void ToUnit(LinearPowerDensityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index 007e99449e..3aaf90c4d9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -617,7 +617,7 @@ public void ToUnit(LuminosityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index dcb107c35f..02d89fa3ec 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(LuminousFluxUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index fcd3954377..780180965e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(LuminousIntensityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index 174b05b5bc..a3f65674a3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -389,7 +389,7 @@ public void ToUnit(MagneticFieldUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index acee8f296b..60625a68ac 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(MagneticFluxUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index b6e2f93739..5f4acd87eb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(MagnetizationUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index 4f1778b29c..16df09d64a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -1947,7 +1947,7 @@ public void ToUnit(MassConcentrationUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index d4696be3d2..8cad9926bd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -1549,7 +1549,7 @@ public void ToUnit(MassFlowUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index 54a6e654cf..3399d668b2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -593,7 +593,7 @@ public void ToUnit(MassFluxUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index 1cdfeb11b5..869a440e1c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -1025,7 +1025,7 @@ public void ToUnit(MassFractionUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index 12f6d91b6e..6c67b27cce 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -1137,7 +1137,7 @@ public void ToUnit(MassMomentOfInertiaUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index aee8d32ea4..fdb0825f8b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -2023,7 +2023,7 @@ public void ToUnit(MassUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index d02524f56e..a8d1e7fc9e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(MolarEnergyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index 78a88ecb39..cb52e3964c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(MolarEntropyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index ffe0f30f77..3f7389ff63 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -881,7 +881,7 @@ public void ToUnit(MolarMassUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index 923b01a6b3..cbe5fe4d20 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -582,7 +582,7 @@ public void ToUnit(MolarityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index af5bee7872..bb94e4b69b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(PermeabilityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index 1a1aa929fa..2525d5107b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(PermittivityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs index 88b7bcfa81..66e66d2830 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs @@ -355,7 +355,7 @@ public void ToUnit(PorousMediumPermeabilityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index 9888200c48..4ad5f27936 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -1593,7 +1593,7 @@ public void ToUnit(PowerDensityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index 3cd613b917..8e70929d4f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -277,7 +277,7 @@ public void ToUnit(PowerRatioUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index 84e4e66f28..131da2b337 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -38,63 +38,63 @@ namespace UnitsNet.Tests // ReSharper disable once PartialTypeWithSinglePart public abstract partial class PowerTestsBase : QuantityTestsBase { - protected abstract double BoilerHorsepowerInOneWatt { get; } - protected abstract double BritishThermalUnitsPerHourInOneWatt { get; } - protected abstract double DecawattsInOneWatt { get; } - protected abstract double DeciwattsInOneWatt { get; } - protected abstract double ElectricalHorsepowerInOneWatt { get; } - protected abstract double FemtowattsInOneWatt { get; } - protected abstract double GigajoulesPerHourInOneWatt { get; } - protected abstract double GigawattsInOneWatt { get; } - protected abstract double HydraulicHorsepowerInOneWatt { get; } - protected abstract double JoulesPerHourInOneWatt { get; } - protected abstract double KilobritishThermalUnitsPerHourInOneWatt { get; } - protected abstract double KilojoulesPerHourInOneWatt { get; } - protected abstract double KilowattsInOneWatt { get; } - protected abstract double MechanicalHorsepowerInOneWatt { get; } - protected abstract double MegabritishThermalUnitsPerHourInOneWatt { get; } - protected abstract double MegajoulesPerHourInOneWatt { get; } - protected abstract double MegawattsInOneWatt { get; } - protected abstract double MetricHorsepowerInOneWatt { get; } - protected abstract double MicrowattsInOneWatt { get; } - protected abstract double MillijoulesPerHourInOneWatt { get; } - protected abstract double MilliwattsInOneWatt { get; } - protected abstract double NanowattsInOneWatt { get; } - protected abstract double PetawattsInOneWatt { get; } - protected abstract double PicowattsInOneWatt { get; } - protected abstract double TerawattsInOneWatt { get; } - protected abstract double WattsInOneWatt { get; } + protected abstract decimal BoilerHorsepowerInOneWatt { get; } + protected abstract decimal BritishThermalUnitsPerHourInOneWatt { get; } + protected abstract decimal DecawattsInOneWatt { get; } + protected abstract decimal DeciwattsInOneWatt { get; } + protected abstract decimal ElectricalHorsepowerInOneWatt { get; } + protected abstract decimal FemtowattsInOneWatt { get; } + protected abstract decimal GigajoulesPerHourInOneWatt { get; } + protected abstract decimal GigawattsInOneWatt { get; } + protected abstract decimal HydraulicHorsepowerInOneWatt { get; } + protected abstract decimal JoulesPerHourInOneWatt { get; } + protected abstract decimal KilobritishThermalUnitsPerHourInOneWatt { get; } + protected abstract decimal KilojoulesPerHourInOneWatt { get; } + protected abstract decimal KilowattsInOneWatt { get; } + protected abstract decimal MechanicalHorsepowerInOneWatt { get; } + protected abstract decimal MegabritishThermalUnitsPerHourInOneWatt { get; } + protected abstract decimal MegajoulesPerHourInOneWatt { get; } + protected abstract decimal MegawattsInOneWatt { get; } + protected abstract decimal MetricHorsepowerInOneWatt { get; } + protected abstract decimal MicrowattsInOneWatt { get; } + protected abstract decimal MillijoulesPerHourInOneWatt { get; } + protected abstract decimal MilliwattsInOneWatt { get; } + protected abstract decimal NanowattsInOneWatt { get; } + protected abstract decimal PetawattsInOneWatt { get; } + protected abstract decimal PicowattsInOneWatt { get; } + protected abstract decimal TerawattsInOneWatt { get; } + protected abstract decimal WattsInOneWatt { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BoilerHorsepowerTolerance { get { return 1e-5; } } - protected virtual double BritishThermalUnitsPerHourTolerance { get { return 1e-5; } } - protected virtual double DecawattsTolerance { get { return 1e-5; } } - protected virtual double DeciwattsTolerance { get { return 1e-5; } } - protected virtual double ElectricalHorsepowerTolerance { get { return 1e-5; } } - protected virtual double FemtowattsTolerance { get { return 1e-5; } } - protected virtual double GigajoulesPerHourTolerance { get { return 1e-5; } } - protected virtual double GigawattsTolerance { get { return 1e-5; } } - protected virtual double HydraulicHorsepowerTolerance { get { return 1e-5; } } - protected virtual double JoulesPerHourTolerance { get { return 1e-5; } } - protected virtual double KilobritishThermalUnitsPerHourTolerance { get { return 1e-5; } } - protected virtual double KilojoulesPerHourTolerance { get { return 1e-5; } } - protected virtual double KilowattsTolerance { get { return 1e-5; } } - protected virtual double MechanicalHorsepowerTolerance { get { return 1e-5; } } - protected virtual double MegabritishThermalUnitsPerHourTolerance { get { return 1e-5; } } - protected virtual double MegajoulesPerHourTolerance { get { return 1e-5; } } - protected virtual double MegawattsTolerance { get { return 1e-5; } } - protected virtual double MetricHorsepowerTolerance { get { return 1e-5; } } - protected virtual double MicrowattsTolerance { get { return 1e-5; } } - protected virtual double MillijoulesPerHourTolerance { get { return 1e-5; } } - protected virtual double MilliwattsTolerance { get { return 1e-5; } } - protected virtual double NanowattsTolerance { get { return 1e-5; } } - protected virtual double PetawattsTolerance { get { return 1e-5; } } - protected virtual double PicowattsTolerance { get { return 1e-5; } } - protected virtual double TerawattsTolerance { get { return 1e-5; } } - protected virtual double WattsTolerance { get { return 1e-5; } } + protected virtual decimal BoilerHorsepowerTolerance { get { return 1e-9m; } } + protected virtual decimal BritishThermalUnitsPerHourTolerance { get { return 1e-9m; } } + protected virtual decimal DecawattsTolerance { get { return 1e-9m; } } + protected virtual decimal DeciwattsTolerance { get { return 1e-9m; } } + protected virtual decimal ElectricalHorsepowerTolerance { get { return 1e-9m; } } + protected virtual decimal FemtowattsTolerance { get { return 1e-9m; } } + protected virtual decimal GigajoulesPerHourTolerance { get { return 1e-9m; } } + protected virtual decimal GigawattsTolerance { get { return 1e-9m; } } + protected virtual decimal HydraulicHorsepowerTolerance { get { return 1e-9m; } } + protected virtual decimal JoulesPerHourTolerance { get { return 1e-9m; } } + protected virtual decimal KilobritishThermalUnitsPerHourTolerance { get { return 1e-9m; } } + protected virtual decimal KilojoulesPerHourTolerance { get { return 1e-9m; } } + protected virtual decimal KilowattsTolerance { get { return 1e-9m; } } + protected virtual decimal MechanicalHorsepowerTolerance { get { return 1e-9m; } } + protected virtual decimal MegabritishThermalUnitsPerHourTolerance { get { return 1e-9m; } } + protected virtual decimal MegajoulesPerHourTolerance { get { return 1e-9m; } } + protected virtual decimal MegawattsTolerance { get { return 1e-9m; } } + protected virtual decimal MetricHorsepowerTolerance { get { return 1e-9m; } } + protected virtual decimal MicrowattsTolerance { get { return 1e-9m; } } + protected virtual decimal MillijoulesPerHourTolerance { get { return 1e-9m; } } + protected virtual decimal MilliwattsTolerance { get { return 1e-9m; } } + protected virtual decimal NanowattsTolerance { get { return 1e-9m; } } + protected virtual decimal PetawattsTolerance { get { return 1e-9m; } } + protected virtual decimal PicowattsTolerance { get { return 1e-9m; } } + protected virtual decimal TerawattsTolerance { get { return 1e-9m; } } + protected virtual decimal WattsTolerance { get { return 1e-9m; } } // ReSharper restore VirtualMemberNeverOverriden.Global - protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PowerUnit unit) + protected (decimal UnitsInBaseUnit, decimal Tolerence) GetConversionFactor(PowerUnit unit) { return unit switch { @@ -1050,7 +1050,7 @@ public void ToUnit(PowerUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index c489b22624..5fe20f091c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -1285,7 +1285,7 @@ public void ToUnit(PressureChangeRateUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index 3db47ed7e7..cf6967f71a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -2633,7 +2633,7 @@ public void ToUnit(PressureUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index 989c017044..4ea643a545 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -253,7 +253,7 @@ public void ToUnit(RatioChangeRateUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index 8714c6f6a3..861ea209f2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -389,7 +389,7 @@ public void ToUnit(RatioUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs index 8c4ddb264c..8391a912fe 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(ReactiveEnergyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs index 807b553fda..feed495b61 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs @@ -321,7 +321,7 @@ public void ToUnit(ReactivePowerUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs index 93590fd301..777ed892bc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs @@ -559,7 +559,7 @@ public void ToUnit(ReciprocalAreaUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs index 3de7afaf9e..9ea9f3f6dd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs @@ -765,7 +765,7 @@ public void ToUnit(ReciprocalLengthUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index 60f67c7468..1f04da75d7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(RelativeHumidityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index f0cc297b7e..2a77ca24bb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -345,7 +345,7 @@ public void ToUnit(RotationalAccelerationUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index a2df678911..895645ecf5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -1059,7 +1059,7 @@ public void ToUnit(RotationalSpeedUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index 7880b8d001..9fa1017fcf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -547,7 +547,7 @@ public void ToUnit(RotationalStiffnessPerLengthUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index 8557dab512..77d59aa2d4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -2791,7 +2791,7 @@ public void ToUnit(RotationalStiffnessUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs index 427c4da867..736372bbe1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(ScalarUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index 6fe1a3602c..25caa612e6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(SolidAngleUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index 32be1e830a..64160a096f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -1171,7 +1171,7 @@ public void ToUnit(SpecificEnergyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index b58e37b641..dc46b24d03 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -515,7 +515,7 @@ public void ToUnit(SpecificEntropyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs index e0e7e9e8cc..d577065a72 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs @@ -321,7 +321,7 @@ public void ToUnit(SpecificFuelConsumptionUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index 44c9025100..4b3b657d2d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(SpecificVolumeUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index daf5cffeae..4210c1a039 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -763,7 +763,7 @@ public void ToUnit(SpecificWeightUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index 9ef94f5cab..fa482d3228 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -1897,7 +1897,7 @@ public void ToUnit(SpeedUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs index 7dfaf4c928..75a3ed37d2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs @@ -491,7 +491,7 @@ public void ToUnit(StandardVolumeFlowUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index 6e8098579d..3d67ad09fc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -525,7 +525,7 @@ public void ToUnit(TemperatureChangeRateUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index 7febab8e92..5d8b5496c2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -491,7 +491,7 @@ public void ToUnit(TemperatureDeltaUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs index e0a6f79454..0615daf30e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs @@ -321,7 +321,7 @@ public void ToUnit(TemperatureGradientUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index fe54557914..44de9d28d1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -525,7 +525,7 @@ public void ToUnit(TemperatureUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index f9ba3e2d05..3347f067f8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -253,7 +253,7 @@ public void ToUnit(ThermalConductivityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index 00f985ad3e..f81e24bad8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -389,7 +389,7 @@ public void ToUnit(ThermalResistanceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs index 4d7495ee03..23cde17010 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs @@ -971,7 +971,7 @@ public void ToUnit(TorquePerLengthUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index 322306450f..df2ff38bce 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -1107,7 +1107,7 @@ public void ToUnit(TorqueUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index 65fd4b5012..0dd6738ce2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(TurbidityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index 36661f561c..a7d6532013 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(VitaminAUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index d807ec47aa..5e1a8bf0f9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -889,7 +889,7 @@ public void ToUnit(VolumeConcentrationUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs index 722f63a1d7..ac720c72b8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs @@ -253,7 +253,7 @@ public void ToUnit(VolumeFlowPerAreaUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index caf0e209b2..7df104aa26 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -3955,7 +3955,7 @@ public void ToUnit(VolumeFlowUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index 98f4ce00c7..93fae6f962 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -423,7 +423,7 @@ public void ToUnit(VolumePerLengthUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index 4447d491b4..4a05b0d952 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -2949,7 +2949,7 @@ public void ToUnit(VolumeUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs index 030c251bde..7e1c9f3c69 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs @@ -491,7 +491,7 @@ public void ToUnit(VolumetricHeatCapacityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index 683a9313ae..3bf9cafc76 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -533,7 +533,7 @@ public void ToUnit(WarpingMomentOfInertiaUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/IntOverloadTests.cs b/UnitsNet.Tests/IntOverloadTests.cs index bf63007ba7..9d059dcc46 100644 --- a/UnitsNet.Tests/IntOverloadTests.cs +++ b/UnitsNet.Tests/IntOverloadTests.cs @@ -18,7 +18,7 @@ public static void CreatingQuantityWithDoubleBackingFieldFromIntReturnsCorrectVa public static void CreatingQuantityWithIntBackingFieldFromIntReturnsCorrectValue() { Power power = Power.FromWatts(1); - Assert.Equal(1.0, power.Watts); + Assert.Equal(1.0m, power.Watts); } } } diff --git a/UnitsNet.Tests/LongOverloadTests.cs b/UnitsNet.Tests/LongOverloadTests.cs index fd54377f08..ba5c00a538 100644 --- a/UnitsNet.Tests/LongOverloadTests.cs +++ b/UnitsNet.Tests/LongOverloadTests.cs @@ -18,7 +18,7 @@ public static void CreatingQuantityWithDoubleBackingFieldFromLongReturnsCorrectV public static void CreatingQuantityWithLongBackingFieldFromLongReturnsCorrectValue() { Power power = Power.FromWatts(1L); - Assert.Equal(1.0, power.Watts); + Assert.Equal(1.0m, power.Watts); } } } diff --git a/UnitsNet.Tests/UnitConverterTest.cs b/UnitsNet.Tests/UnitConverterTest.cs index 421d7fef23..fab0694f48 100644 --- a/UnitsNet.Tests/UnitConverterTest.cs +++ b/UnitsNet.Tests/UnitConverterTest.cs @@ -112,8 +112,8 @@ public void ConversionForUnitsOfCustomQuantity(double fromValue, HowMuchUnit fro { // Intentionally don't map conversion Some->Some, it is not necessary var unitConverter = new UnitConverter(); - unitConverter.SetConversionFunction(HowMuchUnit.Some, HowMuchUnit.ATon, x => new HowMuch(x.Value * 2, HowMuchUnit.ATon)); - unitConverter.SetConversionFunction(HowMuchUnit.Some, HowMuchUnit.AShitTon, x => new HowMuch(x.Value * 10, HowMuchUnit.AShitTon)); + unitConverter.SetConversionFunction(HowMuchUnit.Some, HowMuchUnit.ATon, x => new HowMuch((double)x.Value * 2, HowMuchUnit.ATon)); + unitConverter.SetConversionFunction(HowMuchUnit.Some, HowMuchUnit.AShitTon, x => new HowMuch((double)x.Value * 10, HowMuchUnit.AShitTon)); var foundConversionFunction = unitConverter.GetConversionFunction(fromUnit, toUnit); var converted = foundConversionFunction(new HowMuch(fromValue, fromUnit)); diff --git a/UnitsNet/Comparison.cs b/UnitsNet/Comparison.cs index 575707e6b5..ac6726c3e2 100644 --- a/UnitsNet/Comparison.cs +++ b/UnitsNet/Comparison.cs @@ -65,6 +65,61 @@ public static bool Equals(double referenceValue, double otherValue, double toler } } + /// + /// + /// Checks if two values are equal with a given relative or absolute tolerance. + /// + /// + /// Relative tolerance is defined as the maximum allowable absolute difference between + /// and + /// as a percentage of . A relative tolerance of + /// 0.01 means the + /// absolute difference of and must be within +/- + /// 1%. + /// + /// In this example, the two values will be equal if the value of b is within +/- 1% of a. + /// + /// Equals(a, b, 0.01, ComparisonType.Relative); + /// + /// + /// + /// + /// Absolute tolerance is defined as the maximum allowable absolute difference between + /// and + /// as a fixed number. + /// + /// In this example, the two values will be equal if abs( - + /// ) <= 0.01 + /// + /// Equals(a, b, 0.01, ComparisonType.Absolute); + /// + /// + /// + /// + /// + /// The reference value. If using relative tolerance, it is the value which the relative + /// tolerance will be calculated against. + /// + /// The value to compare to. + /// The absolute or relative tolerance value. Must be greater than or equal to 0. + /// Whether the tolerance is absolute or relative. + /// + public static bool Equals(decimal referenceValue, decimal otherValue, decimal tolerance, ComparisonType comparisonType) + { + if (tolerance < 0) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); + + switch (comparisonType) + { + case ComparisonType.Relative: + return EqualsRelative(referenceValue, otherValue, tolerance); + case ComparisonType.Absolute: + return EqualsAbsolute(referenceValue, otherValue, tolerance); + default: + throw new InvalidOperationException("The given ComparisonType is not supported."); + } + } + /// /// Checks if two values are equal with a given relative tolerance. /// @@ -95,6 +150,36 @@ public static bool EqualsRelative(double referenceValue, double otherValue, doub return Math.Abs(referenceValue - otherValue) <= maxVariation; } + /// + /// Checks if two values are equal with a given relative tolerance. + /// + /// Relative tolerance is defined as the maximum allowable absolute difference between + /// and + /// as a percentage of . A relative tolerance of + /// 0.01 means the + /// absolute difference of and must be within +/- + /// 1%. + /// + /// In this example, the two values will be equal if the value of b is within +/- 1% of a. + /// + /// EqualsRelative(a, b, 0.01); + /// + /// + /// + /// + /// The reference value which the tolerance will be calculated against. + /// The value to compare to. + /// The relative tolerance. Must be greater than or equal to 0. + /// True if the two values are equal within the given relative tolerance, otherwise false. + public static bool EqualsRelative(decimal referenceValue, decimal otherValue, decimal tolerance) + { + if (tolerance < 0) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); + + var maxVariation = Math.Abs(referenceValue * tolerance); + return Math.Abs(referenceValue - otherValue) <= maxVariation; + } + /// /// Checks if two values are equal with a given absolute tolerance. /// @@ -121,5 +206,32 @@ public static bool EqualsAbsolute(double value1, double value2, double tolerance return Math.Abs(value1 - value2) <= tolerance; } + + /// + /// Checks if two values are equal with a given absolute tolerance. + /// + /// Absolute tolerance is defined as the maximum allowable absolute difference between + /// and + /// as a fixed number. + /// + /// In this example, the two values will be equal if abs( - + /// ) <= 0.01 + /// + /// Equals(a, b, 0.01, ComparisonType.Absolute); + /// + /// + /// + /// + /// The first value. + /// The second value. + /// The absolute tolerance. Must be greater than or equal to 0. + /// True if the two values are equal within the given absolute tolerance, otherwise false. + public static bool EqualsAbsolute(decimal value1, decimal value2, decimal tolerance) + { + if (tolerance < 0) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); + + return Math.Abs(value1 - value2) <= tolerance; + } } } diff --git a/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs b/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs index 5bd29a877a..a394b46629 100644 --- a/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs +++ b/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs @@ -1,6 +1,8 @@ // Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. +using UnitsNet.Units; + namespace UnitsNet { public partial struct BrakeSpecificFuelConsumption @@ -8,7 +10,7 @@ public partial struct BrakeSpecificFuelConsumption /// Get from times . public static MassFlow operator *(BrakeSpecificFuelConsumption bsfc, Power power) { - return MassFlow.FromKilogramsPerSecond(bsfc.KilogramsPerJoule*power.Watts); + return MassFlow.FromKilogramsPerSecond(bsfc.KilogramsPerJoule * (double)power.Watts); } /// Get from divided by . diff --git a/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs b/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs index e60c5c75d8..609db1ddef 100644 --- a/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs +++ b/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs @@ -2,6 +2,7 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; +using UnitsNet.Units; namespace UnitsNet { @@ -40,7 +41,7 @@ public partial struct MassFlow /// Get from divided by . public static BrakeSpecificFuelConsumption operator /(MassFlow massFlow, Power power) { - return BrakeSpecificFuelConsumption.FromKilogramsPerJoule(massFlow.KilogramsPerSecond / power.Watts); + return BrakeSpecificFuelConsumption.FromKilogramsPerJoule(massFlow.KilogramsPerSecond / (double)power.Watts); } /// Get from times . diff --git a/UnitsNet/CustomCode/Quantities/Power.extra.cs b/UnitsNet/CustomCode/Quantities/Power.extra.cs index 187c2740fc..61739b4054 100644 --- a/UnitsNet/CustomCode/Quantities/Power.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Power.extra.cs @@ -2,6 +2,7 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; +using UnitsNet.Units; namespace UnitsNet { @@ -24,87 +25,87 @@ public PowerRatio ToPowerRatio() /// Get from times . public static Energy operator *(Power power, TimeSpan time) { - return Energy.FromJoules(power.Watts * time.TotalSeconds); + return Energy.FromJoules((double)power.Watts * time.TotalSeconds); } /// Get from times . public static Energy operator *(TimeSpan time, Power power) { - return Energy.FromJoules(power.Watts * time.TotalSeconds); + return Energy.FromJoules((double)power.Watts * time.TotalSeconds); } /// Get from times . public static Energy operator *(Power power, Duration duration) { - return Energy.FromJoules(power.Watts * duration.Seconds); + return Energy.FromJoules((double)power.Watts * duration.Seconds); } /// Get from times . public static Energy operator *(Duration duration, Power power) { - return Energy.FromJoules(power.Watts * duration.Seconds); + return Energy.FromJoules((double)power.Watts * duration.Seconds); } /// Get from divided by . public static Force operator /(Power power, Speed speed) { - return Force.FromNewtons(power.Watts / speed.MetersPerSecond); + return Force.FromNewtons((double)power.Watts / speed.MetersPerSecond); } /// Get from divided by . public static Torque operator /(Power power, RotationalSpeed rotationalSpeed) { - return Torque.FromNewtonMeters(power.Watts / rotationalSpeed.RadiansPerSecond); + return Torque.FromNewtonMeters((double)power.Watts / rotationalSpeed.RadiansPerSecond); } /// Get from divided by . public static RotationalSpeed operator /(Power power, Torque torque) { - return RotationalSpeed.FromRadiansPerSecond(power.Watts / torque.NewtonMeters); + return RotationalSpeed.FromRadiansPerSecond((double)power.Watts / torque.NewtonMeters); } /// Get from times . public static MassFlow operator *(Power power, BrakeSpecificFuelConsumption bsfc) { - return MassFlow.FromKilogramsPerSecond(bsfc.KilogramsPerJoule * power.Watts); + return MassFlow.FromKilogramsPerSecond(bsfc.KilogramsPerJoule * (double)power.Watts); } /// Get from divided by . public static SpecificEnergy operator /(Power power, MassFlow massFlow) { - return SpecificEnergy.FromJoulesPerKilogram(power.Watts / massFlow.KilogramsPerSecond); + return SpecificEnergy.FromJoulesPerKilogram((double)power.Watts / massFlow.KilogramsPerSecond); } /// Get from divided by . public static MassFlow operator /(Power power, SpecificEnergy specificEnergy) { - return MassFlow.FromKilogramsPerSecond(power.Watts / specificEnergy.JoulesPerKilogram); + return MassFlow.FromKilogramsPerSecond((double)power.Watts / specificEnergy.JoulesPerKilogram); } /// Get from divided by . public static HeatFlux operator /(Power power, Area area) { - return HeatFlux.FromWattsPerSquareMeter(power.Watts / area.SquareMeters); + return HeatFlux.FromWattsPerSquareMeter((double)power.Watts / area.SquareMeters); } /// Get from divided by . public static Area operator /(Power power, HeatFlux heatFlux) { - return Area.FromSquareMeters( power.Watts / heatFlux.WattsPerSquareMeter ); + return Area.FromSquareMeters((double)power.Watts / heatFlux.WattsPerSquareMeter ); } /// Calculate from divided by . /// Electric power is defined as P = U * I, so I = P / U. public static ElectricCurrent operator /(Power power, ElectricPotential potential) { - return ElectricCurrent.FromAmperes(power.Watts / potential.Volts); + return ElectricCurrent.FromAmperes((double)power.Watts / potential.Volts); } /// Calculate from divided by . /// Electric power is defined as P = U * I, so I = P / U. public static ElectricPotential operator /(Power power, ElectricCurrent current) { - return ElectricPotential.FromVolts(power.Watts / current.Amperes); + return ElectricPotential.FromVolts((double)power.Watts / current.Amperes); } } } diff --git a/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs b/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs index f563f720ae..e4c4f07fe6 100644 --- a/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs +++ b/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs @@ -21,7 +21,7 @@ public PowerRatio(Power power) nameof(power), "The base-10 logarithm of a number ≤ 0 is undefined. Power must be greater than 0 W."); // P(dBW) = 10*log10(value(W)/reference(W)) - _value = 10 * Math.Log10(power.Watts / 1); + _value = 10 * Math.Log10((double)power.Watts); _unit = PowerRatioUnit.DecibelWatt; } diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 820cb3a395..fbcb6ab303 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -149,6 +149,9 @@ public Acceleration(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -769,7 +772,7 @@ public bool Equals(Acceleration other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -795,10 +798,9 @@ public override int GetHashCode() public double As(AccelerationUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -819,10 +821,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is AccelerationUnit unitAsAccelerationUnit)) + if (!(unit is AccelerationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AccelerationUnit)} is supported.", nameof(unit)); - return As(unitAsAccelerationUnit); + return (double)As(typedUnit); } /// @@ -869,10 +871,10 @@ public Acceleration ToUnit(AccelerationUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AccelerationUnit unitAsAccelerationUnit)) + if (!(unit is AccelerationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AccelerationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAccelerationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 6b796bdd8a..6575dc99be 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -150,6 +150,9 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -774,7 +777,7 @@ public bool Equals(AmountOfSubstance other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -800,10 +803,9 @@ public override int GetHashCode() public double As(AmountOfSubstanceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -824,10 +826,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is AmountOfSubstanceUnit unitAsAmountOfSubstanceUnit)) + if (!(unit is AmountOfSubstanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmountOfSubstanceUnit)} is supported.", nameof(unit)); - return As(unitAsAmountOfSubstanceUnit); + return (double)As(typedUnit); } /// @@ -874,10 +876,10 @@ public AmountOfSubstance ToUnit(AmountOfSubstanceUnit unit, UnitConverter unitCo /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AmountOfSubstanceUnit unitAsAmountOfSubstanceUnit)) + if (!(unit is AmountOfSubstanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmountOfSubstanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAmountOfSubstanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index 05d7dfc95a..88ec3815eb 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -139,6 +139,9 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -573,7 +576,7 @@ public bool Equals(AmplitudeRatio other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -599,10 +602,9 @@ public override int GetHashCode() public double As(AmplitudeRatioUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -623,10 +625,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is AmplitudeRatioUnit unitAsAmplitudeRatioUnit)) + if (!(unit is AmplitudeRatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmplitudeRatioUnit)} is supported.", nameof(unit)); - return As(unitAsAmplitudeRatioUnit); + return (double)As(typedUnit); } /// @@ -673,10 +675,10 @@ public AmplitudeRatio ToUnit(AmplitudeRatioUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AmplitudeRatioUnit unitAsAmplitudeRatioUnit)) + if (!(unit is AmplitudeRatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmplitudeRatioUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAmplitudeRatioUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 55d9a88517..03cb0fb025 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -151,6 +151,9 @@ public Angle(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -805,7 +808,7 @@ public bool Equals(Angle 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 thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -831,10 +834,9 @@ public override int GetHashCode() public double As(AngleUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -855,10 +857,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is AngleUnit unitAsAngleUnit)) + if (!(unit is AngleUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AngleUnit)} is supported.", nameof(unit)); - return As(unitAsAngleUnit); + return (double)As(typedUnit); } /// @@ -905,10 +907,10 @@ public Angle ToUnit(AngleUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AngleUnit unitAsAngleUnit)) + if (!(unit is AngleUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AngleUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAngleUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index db89646bfd..5b56ad3a3a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -138,6 +138,9 @@ public ApparentEnergy(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -546,7 +549,7 @@ public bool Equals(ApparentEnergy other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -572,10 +575,9 @@ public override int GetHashCode() public double As(ApparentEnergyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -596,10 +598,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ApparentEnergyUnit unitAsApparentEnergyUnit)) + if (!(unit is ApparentEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentEnergyUnit)} is supported.", nameof(unit)); - return As(unitAsApparentEnergyUnit); + return (double)As(typedUnit); } /// @@ -646,10 +648,10 @@ public ApparentEnergy ToUnit(ApparentEnergyUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ApparentEnergyUnit unitAsApparentEnergyUnit)) + if (!(unit is ApparentEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentEnergyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsApparentEnergyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index 403251e02c..0dd50f5778 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -139,6 +139,9 @@ public ApparentPower(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -565,7 +568,7 @@ public bool Equals(ApparentPower other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -591,10 +594,9 @@ public override int GetHashCode() public double As(ApparentPowerUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -615,10 +617,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ApparentPowerUnit unitAsApparentPowerUnit)) + if (!(unit is ApparentPowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentPowerUnit)} is supported.", nameof(unit)); - return As(unitAsApparentPowerUnit); + return (double)As(typedUnit); } /// @@ -665,10 +667,10 @@ public ApparentPower ToUnit(ApparentPowerUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ApparentPowerUnit unitAsApparentPowerUnit)) + if (!(unit is ApparentPowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentPowerUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsApparentPowerUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index e7b786a82d..6abacce16a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -149,6 +149,9 @@ public Area(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -782,7 +785,7 @@ public bool Equals(Area 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 thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -808,10 +811,9 @@ public override int GetHashCode() public double As(AreaUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -832,10 +834,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is AreaUnit unitAsAreaUnit)) + if (!(unit is AreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaUnit)} is supported.", nameof(unit)); - return As(unitAsAreaUnit); + return (double)As(typedUnit); } /// @@ -882,10 +884,10 @@ public Area ToUnit(AreaUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AreaUnit unitAsAreaUnit)) + if (!(unit is AreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAreaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index 76e73b46b3..4cb829edfa 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -136,6 +136,9 @@ public AreaDensity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -508,7 +511,7 @@ public bool Equals(AreaDensity other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -534,10 +537,9 @@ public override int GetHashCode() public double As(AreaDensityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -558,10 +560,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is AreaDensityUnit unitAsAreaDensityUnit)) + if (!(unit is AreaDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaDensityUnit)} is supported.", nameof(unit)); - return As(unitAsAreaDensityUnit); + return (double)As(typedUnit); } /// @@ -608,10 +610,10 @@ public AreaDensity ToUnit(AreaDensityUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AreaDensityUnit unitAsAreaDensityUnit)) + if (!(unit is AreaDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAreaDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 26632ad748..f98b4a8891 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -141,6 +141,9 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -603,7 +606,7 @@ public bool Equals(AreaMomentOfInertia other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -629,10 +632,9 @@ public override int GetHashCode() public double As(AreaMomentOfInertiaUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -653,10 +655,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is AreaMomentOfInertiaUnit unitAsAreaMomentOfInertiaUnit)) + if (!(unit is AreaMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaMomentOfInertiaUnit)} is supported.", nameof(unit)); - return As(unitAsAreaMomentOfInertiaUnit); + return (double)As(typedUnit); } /// @@ -703,10 +705,10 @@ public AreaMomentOfInertia ToUnit(AreaMomentOfInertiaUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AreaMomentOfInertiaUnit unitAsAreaMomentOfInertiaUnit)) + if (!(unit is AreaMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaMomentOfInertiaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAreaMomentOfInertiaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index 1ce28dd1dd..7a60204588 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -164,7 +164,8 @@ public BitRate(decimal value, UnitSystem unitSystem) /// public decimal Value => _value; - double IQuantity.Value => (double) _value; + /// + QuantityValue IQuantity.Value => _value; /// decimal IDecimalQuantity.Value => _value; @@ -190,134 +191,134 @@ public BitRate(decimal value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double BitsPerSecond => As(BitRateUnit.BitPerSecond); + public decimal BitsPerSecond => As(BitRateUnit.BitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double BytesPerSecond => As(BitRateUnit.BytePerSecond); + public decimal BytesPerSecond => As(BitRateUnit.BytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double ExabitsPerSecond => As(BitRateUnit.ExabitPerSecond); + public decimal ExabitsPerSecond => As(BitRateUnit.ExabitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double ExabytesPerSecond => As(BitRateUnit.ExabytePerSecond); + public decimal ExabytesPerSecond => As(BitRateUnit.ExabytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double ExbibitsPerSecond => As(BitRateUnit.ExbibitPerSecond); + public decimal ExbibitsPerSecond => As(BitRateUnit.ExbibitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double ExbibytesPerSecond => As(BitRateUnit.ExbibytePerSecond); + public decimal ExbibytesPerSecond => As(BitRateUnit.ExbibytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double GibibitsPerSecond => As(BitRateUnit.GibibitPerSecond); + public decimal GibibitsPerSecond => As(BitRateUnit.GibibitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double GibibytesPerSecond => As(BitRateUnit.GibibytePerSecond); + public decimal GibibytesPerSecond => As(BitRateUnit.GibibytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double GigabitsPerSecond => As(BitRateUnit.GigabitPerSecond); + public decimal GigabitsPerSecond => As(BitRateUnit.GigabitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double GigabytesPerSecond => As(BitRateUnit.GigabytePerSecond); + public decimal GigabytesPerSecond => As(BitRateUnit.GigabytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double KibibitsPerSecond => As(BitRateUnit.KibibitPerSecond); + public decimal KibibitsPerSecond => As(BitRateUnit.KibibitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double KibibytesPerSecond => As(BitRateUnit.KibibytePerSecond); + public decimal KibibytesPerSecond => As(BitRateUnit.KibibytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double KilobitsPerSecond => As(BitRateUnit.KilobitPerSecond); + public decimal KilobitsPerSecond => As(BitRateUnit.KilobitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double KilobytesPerSecond => As(BitRateUnit.KilobytePerSecond); + public decimal KilobytesPerSecond => As(BitRateUnit.KilobytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MebibitsPerSecond => As(BitRateUnit.MebibitPerSecond); + public decimal MebibitsPerSecond => As(BitRateUnit.MebibitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MebibytesPerSecond => As(BitRateUnit.MebibytePerSecond); + public decimal MebibytesPerSecond => As(BitRateUnit.MebibytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MegabitsPerSecond => As(BitRateUnit.MegabitPerSecond); + public decimal MegabitsPerSecond => As(BitRateUnit.MegabitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MegabytesPerSecond => As(BitRateUnit.MegabytePerSecond); + public decimal MegabytesPerSecond => As(BitRateUnit.MegabytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double PebibitsPerSecond => As(BitRateUnit.PebibitPerSecond); + public decimal PebibitsPerSecond => As(BitRateUnit.PebibitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double PebibytesPerSecond => As(BitRateUnit.PebibytePerSecond); + public decimal PebibytesPerSecond => As(BitRateUnit.PebibytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double PetabitsPerSecond => As(BitRateUnit.PetabitPerSecond); + public decimal PetabitsPerSecond => As(BitRateUnit.PetabitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double PetabytesPerSecond => As(BitRateUnit.PetabytePerSecond); + public decimal PetabytesPerSecond => As(BitRateUnit.PetabytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double TebibitsPerSecond => As(BitRateUnit.TebibitPerSecond); + public decimal TebibitsPerSecond => As(BitRateUnit.TebibitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double TebibytesPerSecond => As(BitRateUnit.TebibytePerSecond); + public decimal TebibytesPerSecond => As(BitRateUnit.TebibytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double TerabitsPerSecond => As(BitRateUnit.TerabitPerSecond); + public decimal TerabitsPerSecond => As(BitRateUnit.TerabitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double TerabytesPerSecond => As(BitRateUnit.TerabytePerSecond); + public decimal TerabytesPerSecond => As(BitRateUnit.TerabytePerSecond); #endregion @@ -898,7 +899,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRa } /// Get ratio value from dividing by . - public static double operator /(BitRate left, BitRate right) + public static decimal operator /(BitRate left, BitRate right) { return left.BitsPerSecond / right.BitsPerSecond; } @@ -986,13 +987,13 @@ public int CompareTo(BitRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(BitRate other, double tolerance, ComparisonType comparisonType) + public bool Equals(BitRate other, decimal 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); + decimal thisValue = this.Value; + decimal otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1014,17 +1015,21 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(BitRateUnit unit) + public decimal As(BitRateUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; + + return GetValueAs(unit); + } - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + double IQuantity.As(BitRateUnit unit) + { + return (double)As(unit); } /// - public double As(UnitSystem unitSystem) + public decimal As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1038,13 +1043,19 @@ public double As(UnitSystem unitSystem) return As(firstUnitInfo.Value); } + /// + double IQuantity.As(UnitSystem unitSystem) + { + return (double)As(unitSystem); + } + /// double IQuantity.As(Enum unit) { - if (!(unit is BitRateUnit unitAsBitRateUnit)) + if (!(unit is BitRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BitRateUnit)} is supported.", nameof(unit)); - return As(unitAsBitRateUnit); + return (double)As(typedUnit); } /// @@ -1091,10 +1102,10 @@ public BitRate ToUnit(BitRateUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is BitRateUnit unitAsBitRateUnit)) + if (!(unit is BitRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BitRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsBitRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 22e36e45c1..1d80a4fae9 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -138,6 +138,9 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -546,7 +549,7 @@ public bool Equals(BrakeSpecificFuelConsumption other, double tolerance, Compari if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -572,10 +575,9 @@ public override int GetHashCode() public double As(BrakeSpecificFuelConsumptionUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -596,10 +598,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is BrakeSpecificFuelConsumptionUnit unitAsBrakeSpecificFuelConsumptionUnit)) + if (!(unit is BrakeSpecificFuelConsumptionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BrakeSpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - return As(unitAsBrakeSpecificFuelConsumptionUnit); + return (double)As(typedUnit); } /// @@ -646,10 +648,10 @@ public BrakeSpecificFuelConsumption ToUnit(BrakeSpecificFuelConsumptionUnit unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is BrakeSpecificFuelConsumptionUnit unitAsBrakeSpecificFuelConsumptionUnit)) + if (!(unit is BrakeSpecificFuelConsumptionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BrakeSpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsBrakeSpecificFuelConsumptionUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index c049929b5a..42414c4c15 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -145,6 +145,9 @@ public Capacitance(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -625,7 +628,7 @@ public bool Equals(Capacitance other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -651,10 +654,9 @@ public override int GetHashCode() public double As(CapacitanceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -675,10 +677,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is CapacitanceUnit unitAsCapacitanceUnit)) + if (!(unit is CapacitanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CapacitanceUnit)} is supported.", nameof(unit)); - return As(unitAsCapacitanceUnit); + return (double)As(typedUnit); } /// @@ -725,10 +727,10 @@ public Capacitance ToUnit(CapacitanceUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is CapacitanceUnit unitAsCapacitanceUnit)) + if (!(unit is CapacitanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CapacitanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsCapacitanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 1c980e9a81..0825082e41 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -138,6 +138,9 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -546,7 +549,7 @@ public bool Equals(CoefficientOfThermalExpansion other, double tolerance, Compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -572,10 +575,9 @@ public override int GetHashCode() public double As(CoefficientOfThermalExpansionUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -596,10 +598,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is CoefficientOfThermalExpansionUnit unitAsCoefficientOfThermalExpansionUnit)) + if (!(unit is CoefficientOfThermalExpansionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CoefficientOfThermalExpansionUnit)} is supported.", nameof(unit)); - return As(unitAsCoefficientOfThermalExpansionUnit); + return (double)As(typedUnit); } /// @@ -646,10 +648,10 @@ public CoefficientOfThermalExpansion ToUnit(CoefficientOfThermalExpansionUnit un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is CoefficientOfThermalExpansionUnit unitAsCoefficientOfThermalExpansionUnit)) + if (!(unit is CoefficientOfThermalExpansionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CoefficientOfThermalExpansionUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsCoefficientOfThermalExpansionUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs index 24755cc1db..4609bd5ed9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs @@ -142,6 +142,9 @@ public Compressibility(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -622,7 +625,7 @@ public bool Equals(Compressibility other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -648,10 +651,9 @@ public override int GetHashCode() public double As(CompressibilityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -672,10 +674,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is CompressibilityUnit unitAsCompressibilityUnit)) + if (!(unit is CompressibilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CompressibilityUnit)} is supported.", nameof(unit)); - return As(unitAsCompressibilityUnit); + return (double)As(typedUnit); } /// @@ -722,10 +724,10 @@ public Compressibility ToUnit(CompressibilityUnit unit, UnitConverter unitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is CompressibilityUnit unitAsCompressibilityUnit)) + if (!(unit is CompressibilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CompressibilityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsCompressibilityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 470717602d..2d5be5c975 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -189,6 +189,9 @@ public Density(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1465,7 +1468,7 @@ public bool Equals(Density other, double tolerance, ComparisonType comparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1491,10 +1494,9 @@ public override int GetHashCode() public double As(DensityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1515,10 +1517,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is DensityUnit unitAsDensityUnit)) + if (!(unit is DensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DensityUnit)} is supported.", nameof(unit)); - return As(unitAsDensityUnit); + return (double)As(typedUnit); } /// @@ -1565,10 +1567,10 @@ public Density ToUnit(DensityUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is DensityUnit unitAsDensityUnit)) + if (!(unit is DensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index 31dfb5c9b9..09271d58f7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -146,6 +146,9 @@ public Duration(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -708,7 +711,7 @@ public bool Equals(Duration other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -734,10 +737,9 @@ public override int GetHashCode() public double As(DurationUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -758,10 +760,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is DurationUnit unitAsDurationUnit)) + if (!(unit is DurationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DurationUnit)} is supported.", nameof(unit)); - return As(unitAsDurationUnit); + return (double)As(typedUnit); } /// @@ -808,10 +810,10 @@ public Duration ToUnit(DurationUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is DurationUnit unitAsDurationUnit)) + if (!(unit is DurationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DurationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsDurationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index ec17be7043..0f6f562603 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -148,6 +148,9 @@ public DynamicViscosity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -682,7 +685,7 @@ public bool Equals(DynamicViscosity other, double tolerance, ComparisonType comp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -708,10 +711,9 @@ public override int GetHashCode() public double As(DynamicViscosityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -732,10 +734,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is DynamicViscosityUnit unitAsDynamicViscosityUnit)) + if (!(unit is DynamicViscosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DynamicViscosityUnit)} is supported.", nameof(unit)); - return As(unitAsDynamicViscosityUnit); + return (double)As(typedUnit); } /// @@ -782,10 +784,10 @@ public DynamicViscosity ToUnit(DynamicViscosityUnit unit, UnitConverter unitConv /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is DynamicViscosityUnit unitAsDynamicViscosityUnit)) + if (!(unit is DynamicViscosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DynamicViscosityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsDynamicViscosityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 5f6f688ac8..fea3a3bf60 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -139,6 +139,9 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -565,7 +568,7 @@ public bool Equals(ElectricAdmittance other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -591,10 +594,9 @@ public override int GetHashCode() public double As(ElectricAdmittanceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -615,10 +617,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricAdmittanceUnit unitAsElectricAdmittanceUnit)) + if (!(unit is ElectricAdmittanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricAdmittanceUnit)} is supported.", nameof(unit)); - return As(unitAsElectricAdmittanceUnit); + return (double)As(typedUnit); } /// @@ -665,10 +667,10 @@ public ElectricAdmittance ToUnit(ElectricAdmittanceUnit unit, UnitConverter unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricAdmittanceUnit unitAsElectricAdmittanceUnit)) + if (!(unit is ElectricAdmittanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricAdmittanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricAdmittanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index efdcf152cd..01f2c111b2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -143,6 +143,9 @@ public ElectricCharge(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -587,7 +590,7 @@ public bool Equals(ElectricCharge other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -613,10 +616,9 @@ public override int GetHashCode() public double As(ElectricChargeUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -637,10 +639,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricChargeUnit unitAsElectricChargeUnit)) + if (!(unit is ElectricChargeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeUnit)} is supported.", nameof(unit)); - return As(unitAsElectricChargeUnit); + return (double)As(typedUnit); } /// @@ -687,10 +689,10 @@ public ElectricCharge ToUnit(ElectricChargeUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricChargeUnit unitAsElectricChargeUnit)) + if (!(unit is ElectricChargeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricChargeUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 4538e7e215..c4a55f3a99 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -139,6 +139,9 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(ElectricChargeDensity other, double tolerance, ComparisonType if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(ElectricChargeDensityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricChargeDensityUnit unitAsElectricChargeDensityUnit)) + if (!(unit is ElectricChargeDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeDensityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricChargeDensityUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public ElectricChargeDensity ToUnit(ElectricChargeDensityUnit unit, UnitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricChargeDensityUnit unitAsElectricChargeDensityUnit)) + if (!(unit is ElectricChargeDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricChargeDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index f9f766a99d..78722c9767 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -141,6 +141,9 @@ public ElectricConductance(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -549,7 +552,7 @@ public bool Equals(ElectricConductance other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -575,10 +578,9 @@ public override int GetHashCode() public double As(ElectricConductanceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -599,10 +601,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricConductanceUnit unitAsElectricConductanceUnit)) + if (!(unit is ElectricConductanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductanceUnit)} is supported.", nameof(unit)); - return As(unitAsElectricConductanceUnit); + return (double)As(typedUnit); } /// @@ -649,10 +651,10 @@ public ElectricConductance ToUnit(ElectricConductanceUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricConductanceUnit unitAsElectricConductanceUnit)) + if (!(unit is ElectricConductanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricConductanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 8b7f49777a..66547aac20 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -141,6 +141,9 @@ public ElectricConductivity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -549,7 +552,7 @@ public bool Equals(ElectricConductivity other, double tolerance, ComparisonType if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -575,10 +578,9 @@ public override int GetHashCode() public double As(ElectricConductivityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -599,10 +601,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricConductivityUnit unitAsElectricConductivityUnit)) + if (!(unit is ElectricConductivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductivityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricConductivityUnit); + return (double)As(typedUnit); } /// @@ -649,10 +651,10 @@ public ElectricConductivity ToUnit(ElectricConductivityUnit unit, UnitConverter /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricConductivityUnit unitAsElectricConductivityUnit)) + if (!(unit is ElectricConductivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductivityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricConductivityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index 0485881539..fa9b5a42c5 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -143,6 +143,9 @@ public ElectricCurrent(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -641,7 +644,7 @@ public bool Equals(ElectricCurrent other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -667,10 +670,9 @@ public override int GetHashCode() public double As(ElectricCurrentUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -691,10 +693,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricCurrentUnit unitAsElectricCurrentUnit)) + if (!(unit is ElectricCurrentUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentUnit)} is supported.", nameof(unit)); - return As(unitAsElectricCurrentUnit); + return (double)As(typedUnit); } /// @@ -741,10 +743,10 @@ public ElectricCurrent ToUnit(ElectricCurrentUnit unit, UnitConverter unitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricCurrentUnit unitAsElectricCurrentUnit)) + if (!(unit is ElectricCurrentUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricCurrentUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index 8a8989cb79..d1bddfe84c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -141,6 +141,9 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -549,7 +552,7 @@ public bool Equals(ElectricCurrentDensity other, double tolerance, ComparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -575,10 +578,9 @@ public override int GetHashCode() public double As(ElectricCurrentDensityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -599,10 +601,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricCurrentDensityUnit unitAsElectricCurrentDensityUnit)) + if (!(unit is ElectricCurrentDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentDensityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricCurrentDensityUnit); + return (double)As(typedUnit); } /// @@ -649,10 +651,10 @@ public ElectricCurrentDensity ToUnit(ElectricCurrentDensityUnit unit, UnitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricCurrentDensityUnit unitAsElectricCurrentDensityUnit)) + if (!(unit is ElectricCurrentDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricCurrentDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index c5b8587e27..069ecdca43 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -139,6 +139,9 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -565,7 +568,7 @@ public bool Equals(ElectricCurrentGradient other, double tolerance, ComparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -591,10 +594,9 @@ public override int GetHashCode() public double As(ElectricCurrentGradientUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -615,10 +617,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricCurrentGradientUnit unitAsElectricCurrentGradientUnit)) + if (!(unit is ElectricCurrentGradientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentGradientUnit)} is supported.", nameof(unit)); - return As(unitAsElectricCurrentGradientUnit); + return (double)As(typedUnit); } /// @@ -665,10 +667,10 @@ public ElectricCurrentGradient ToUnit(ElectricCurrentGradientUnit unit, UnitConv /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricCurrentGradientUnit unitAsElectricCurrentGradientUnit)) + if (!(unit is ElectricCurrentGradientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentGradientUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricCurrentGradientUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index d49e4be72a..f030a42daa 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -139,6 +139,9 @@ public ElectricField(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(ElectricField other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(ElectricFieldUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricFieldUnit unitAsElectricFieldUnit)) + if (!(unit is ElectricFieldUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricFieldUnit)} is supported.", nameof(unit)); - return As(unitAsElectricFieldUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public ElectricField ToUnit(ElectricFieldUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricFieldUnit unitAsElectricFieldUnit)) + if (!(unit is ElectricFieldUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricFieldUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricFieldUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index fb2435cdce..a7be636acd 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -142,6 +142,9 @@ public ElectricInductance(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -568,7 +571,7 @@ public bool Equals(ElectricInductance other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -594,10 +597,9 @@ public override int GetHashCode() public double As(ElectricInductanceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -618,10 +620,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricInductanceUnit unitAsElectricInductanceUnit)) + if (!(unit is ElectricInductanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricInductanceUnit)} is supported.", nameof(unit)); - return As(unitAsElectricInductanceUnit); + return (double)As(typedUnit); } /// @@ -668,10 +670,10 @@ public ElectricInductance ToUnit(ElectricInductanceUnit unit, UnitConverter unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricInductanceUnit unitAsElectricInductanceUnit)) + if (!(unit is ElectricInductanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricInductanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricInductanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index 3c413afc86..ffd0f55a45 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -140,6 +140,9 @@ public ElectricPotential(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -589,7 +592,7 @@ public bool Equals(ElectricPotential other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -615,10 +618,9 @@ public override int GetHashCode() public double As(ElectricPotentialUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -639,10 +641,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricPotentialUnit unitAsElectricPotentialUnit)) + if (!(unit is ElectricPotentialUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialUnit)} is supported.", nameof(unit)); - return As(unitAsElectricPotentialUnit); + return (double)As(typedUnit); } /// @@ -689,10 +691,10 @@ public ElectricPotential ToUnit(ElectricPotentialUnit unit, UnitConverter unitCo /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricPotentialUnit unitAsElectricPotentialUnit)) + if (!(unit is ElectricPotentialUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricPotentialUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index fa988ad89a..484f7bdad1 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -140,6 +140,9 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -584,7 +587,7 @@ public bool Equals(ElectricPotentialAc other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -610,10 +613,9 @@ public override int GetHashCode() public double As(ElectricPotentialAcUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -634,10 +636,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricPotentialAcUnit unitAsElectricPotentialAcUnit)) + if (!(unit is ElectricPotentialAcUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialAcUnit)} is supported.", nameof(unit)); - return As(unitAsElectricPotentialAcUnit); + return (double)As(typedUnit); } /// @@ -684,10 +686,10 @@ public ElectricPotentialAc ToUnit(ElectricPotentialAcUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricPotentialAcUnit unitAsElectricPotentialAcUnit)) + if (!(unit is ElectricPotentialAcUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialAcUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricPotentialAcUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index 9cc91d8d27..8e26d10e5e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -155,6 +155,9 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -869,7 +872,7 @@ public bool Equals(ElectricPotentialChangeRate other, double tolerance, Comparis if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -895,10 +898,9 @@ public override int GetHashCode() public double As(ElectricPotentialChangeRateUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -919,10 +921,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricPotentialChangeRateUnit unitAsElectricPotentialChangeRateUnit)) + if (!(unit is ElectricPotentialChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsElectricPotentialChangeRateUnit); + return (double)As(typedUnit); } /// @@ -969,10 +971,10 @@ public ElectricPotentialChangeRate ToUnit(ElectricPotentialChangeRateUnit unit, /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricPotentialChangeRateUnit unitAsElectricPotentialChangeRateUnit)) + if (!(unit is ElectricPotentialChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricPotentialChangeRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index 787d8e5f5e..b41d363c53 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -140,6 +140,9 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -584,7 +587,7 @@ public bool Equals(ElectricPotentialDc other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -610,10 +613,9 @@ public override int GetHashCode() public double As(ElectricPotentialDcUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -634,10 +636,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricPotentialDcUnit unitAsElectricPotentialDcUnit)) + if (!(unit is ElectricPotentialDcUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialDcUnit)} is supported.", nameof(unit)); - return As(unitAsElectricPotentialDcUnit); + return (double)As(typedUnit); } /// @@ -684,10 +686,10 @@ public ElectricPotentialDc ToUnit(ElectricPotentialDcUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricPotentialDcUnit unitAsElectricPotentialDcUnit)) + if (!(unit is ElectricPotentialDcUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialDcUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricPotentialDcUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index 29810c8529..d28df3865a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -141,6 +141,9 @@ public ElectricResistance(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -603,7 +606,7 @@ public bool Equals(ElectricResistance other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -629,10 +632,9 @@ public override int GetHashCode() public double As(ElectricResistanceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -653,10 +655,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricResistanceUnit unitAsElectricResistanceUnit)) + if (!(unit is ElectricResistanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistanceUnit)} is supported.", nameof(unit)); - return As(unitAsElectricResistanceUnit); + return (double)As(typedUnit); } /// @@ -703,10 +705,10 @@ public ElectricResistance ToUnit(ElectricResistanceUnit unit, UnitConverter unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricResistanceUnit unitAsElectricResistanceUnit)) + if (!(unit is ElectricResistanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricResistanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index 9fa380d492..40ca57c9e7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -152,6 +152,9 @@ public ElectricResistivity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -758,7 +761,7 @@ public bool Equals(ElectricResistivity other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -784,10 +787,9 @@ public override int GetHashCode() public double As(ElectricResistivityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -808,10 +810,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricResistivityUnit unitAsElectricResistivityUnit)) + if (!(unit is ElectricResistivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistivityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricResistivityUnit); + return (double)As(typedUnit); } /// @@ -858,10 +860,10 @@ public ElectricResistivity ToUnit(ElectricResistivityUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricResistivityUnit unitAsElectricResistivityUnit)) + if (!(unit is ElectricResistivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistivityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricResistivityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index a5e94ca602..6ca9c9f445 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -141,6 +141,9 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -549,7 +552,7 @@ public bool Equals(ElectricSurfaceChargeDensity other, double tolerance, Compari if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -575,10 +578,9 @@ public override int GetHashCode() public double As(ElectricSurfaceChargeDensityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -599,10 +601,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricSurfaceChargeDensityUnit unitAsElectricSurfaceChargeDensityUnit)) + if (!(unit is ElectricSurfaceChargeDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricSurfaceChargeDensityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricSurfaceChargeDensityUnit); + return (double)As(typedUnit); } /// @@ -649,10 +651,10 @@ public ElectricSurfaceChargeDensity ToUnit(ElectricSurfaceChargeDensityUnit unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricSurfaceChargeDensityUnit unitAsElectricSurfaceChargeDensityUnit)) + if (!(unit is ElectricSurfaceChargeDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricSurfaceChargeDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricSurfaceChargeDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index d8d04ae1af..682dd0b1e9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -171,6 +171,9 @@ public Energy(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1194,7 +1197,7 @@ public bool Equals(Energy 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 thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1220,10 +1223,9 @@ public override int GetHashCode() public double As(EnergyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1244,10 +1246,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is EnergyUnit unitAsEnergyUnit)) + if (!(unit is EnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EnergyUnit)} is supported.", nameof(unit)); - return As(unitAsEnergyUnit); + return (double)As(typedUnit); } /// @@ -1294,10 +1296,10 @@ public Energy ToUnit(EnergyUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is EnergyUnit unitAsEnergyUnit)) + if (!(unit is EnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EnergyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsEnergyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index 5a3eed83c2..c8efaf586c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -142,6 +142,9 @@ public Entropy(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -622,7 +625,7 @@ public bool Equals(Entropy other, double tolerance, ComparisonType comparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -648,10 +651,9 @@ public override int GetHashCode() public double As(EntropyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -672,10 +674,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is EntropyUnit unitAsEntropyUnit)) + if (!(unit is EntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EntropyUnit)} is supported.", nameof(unit)); - return As(unitAsEntropyUnit); + return (double)As(typedUnit); } /// @@ -722,10 +724,10 @@ public Entropy ToUnit(EntropyUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is EntropyUnit unitAsEntropyUnit)) + if (!(unit is EntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EntropyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsEntropyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 67478a3e16..b6e6ac5c83 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -150,6 +150,9 @@ public Force(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -787,7 +790,7 @@ public bool Equals(Force 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 thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -813,10 +816,9 @@ public override int GetHashCode() public double As(ForceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -837,10 +839,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ForceUnit unitAsForceUnit)) + if (!(unit is ForceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceUnit)} is supported.", nameof(unit)); - return As(unitAsForceUnit); + return (double)As(typedUnit); } /// @@ -887,10 +889,10 @@ public Force ToUnit(ForceUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ForceUnit unitAsForceUnit)) + if (!(unit is ForceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsForceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index 247b741b2a..71fd87e1fa 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -150,6 +150,9 @@ public ForceChangeRate(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -774,7 +777,7 @@ public bool Equals(ForceChangeRate other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -800,10 +803,9 @@ public override int GetHashCode() public double As(ForceChangeRateUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -824,10 +826,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ForceChangeRateUnit unitAsForceChangeRateUnit)) + if (!(unit is ForceChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsForceChangeRateUnit); + return (double)As(typedUnit); } /// @@ -874,10 +876,10 @@ public ForceChangeRate ToUnit(ForceChangeRateUnit unit, UnitConverter unitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ForceChangeRateUnit unitAsForceChangeRateUnit)) + if (!(unit is ForceChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsForceChangeRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index 820ff9473d..acb10754d3 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -173,6 +173,9 @@ public ForcePerLength(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1217,7 +1220,7 @@ public bool Equals(ForcePerLength other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1243,10 +1246,9 @@ public override int GetHashCode() public double As(ForcePerLengthUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1267,10 +1269,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ForcePerLengthUnit unitAsForcePerLengthUnit)) + if (!(unit is ForcePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForcePerLengthUnit)} is supported.", nameof(unit)); - return As(unitAsForcePerLengthUnit); + return (double)As(typedUnit); } /// @@ -1317,10 +1319,10 @@ public ForcePerLength ToUnit(ForcePerLengthUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ForcePerLengthUnit unitAsForcePerLengthUnit)) + if (!(unit is ForcePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForcePerLengthUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsForcePerLengthUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index 695d03630d..b329151779 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -146,6 +146,9 @@ public Frequency(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -705,7 +708,7 @@ public bool Equals(Frequency other, double tolerance, ComparisonType comparisonT if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -731,10 +734,9 @@ public override int GetHashCode() public double As(FrequencyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -755,10 +757,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is FrequencyUnit unitAsFrequencyUnit)) + if (!(unit is FrequencyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FrequencyUnit)} is supported.", nameof(unit)); - return As(unitAsFrequencyUnit); + return (double)As(typedUnit); } /// @@ -805,10 +807,10 @@ public Frequency ToUnit(FrequencyUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is FrequencyUnit unitAsFrequencyUnit)) + if (!(unit is FrequencyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FrequencyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsFrequencyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index c2a2cfcf02..865c08adc5 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -142,6 +142,9 @@ public FuelEfficiency(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -568,7 +571,7 @@ public bool Equals(FuelEfficiency other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -594,10 +597,9 @@ public override int GetHashCode() public double As(FuelEfficiencyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -618,10 +620,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is FuelEfficiencyUnit unitAsFuelEfficiencyUnit)) + if (!(unit is FuelEfficiencyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FuelEfficiencyUnit)} is supported.", nameof(unit)); - return As(unitAsFuelEfficiencyUnit); + return (double)As(typedUnit); } /// @@ -668,10 +670,10 @@ public FuelEfficiency ToUnit(FuelEfficiencyUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is FuelEfficiencyUnit unitAsFuelEfficiencyUnit)) + if (!(unit is FuelEfficiencyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FuelEfficiencyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsFuelEfficiencyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index 2b0f9a5278..155039b2a2 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -153,6 +153,9 @@ public HeatFlux(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -831,7 +834,7 @@ public bool Equals(HeatFlux other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -857,10 +860,9 @@ public override int GetHashCode() public double As(HeatFluxUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -881,10 +883,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is HeatFluxUnit unitAsHeatFluxUnit)) + if (!(unit is HeatFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatFluxUnit)} is supported.", nameof(unit)); - return As(unitAsHeatFluxUnit); + return (double)As(typedUnit); } /// @@ -931,10 +933,10 @@ public HeatFlux ToUnit(HeatFluxUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is HeatFluxUnit unitAsHeatFluxUnit)) + if (!(unit is HeatFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatFluxUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsHeatFluxUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 2e7f448c7b..a9a420b4cc 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -138,6 +138,9 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -546,7 +549,7 @@ public bool Equals(HeatTransferCoefficient other, double tolerance, ComparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -572,10 +575,9 @@ public override int GetHashCode() public double As(HeatTransferCoefficientUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -596,10 +598,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is HeatTransferCoefficientUnit unitAsHeatTransferCoefficientUnit)) + if (!(unit is HeatTransferCoefficientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatTransferCoefficientUnit)} is supported.", nameof(unit)); - return As(unitAsHeatTransferCoefficientUnit); + return (double)As(typedUnit); } /// @@ -646,10 +648,10 @@ public HeatTransferCoefficient ToUnit(HeatTransferCoefficientUnit unit, UnitConv /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is HeatTransferCoefficientUnit unitAsHeatTransferCoefficientUnit)) + if (!(unit is HeatTransferCoefficientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatTransferCoefficientUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsHeatTransferCoefficientUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index 304d11ab4d..6d897055da 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -142,6 +142,9 @@ public Illuminance(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -568,7 +571,7 @@ public bool Equals(Illuminance other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -594,10 +597,9 @@ public override int GetHashCode() public double As(IlluminanceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -618,10 +620,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is IlluminanceUnit unitAsIlluminanceUnit)) + if (!(unit is IlluminanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IlluminanceUnit)} is supported.", nameof(unit)); - return As(unitAsIlluminanceUnit); + return (double)As(typedUnit); } /// @@ -668,10 +670,10 @@ public Illuminance ToUnit(IlluminanceUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is IlluminanceUnit unitAsIlluminanceUnit)) + if (!(unit is IlluminanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IlluminanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsIlluminanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 880f4a52fb..8d5e3250ed 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -161,7 +161,8 @@ public Information(decimal value, UnitSystem unitSystem) /// public decimal Value => _value; - double IQuantity.Value => (double) _value; + /// + QuantityValue IQuantity.Value => _value; /// decimal IDecimalQuantity.Value => _value; @@ -187,134 +188,134 @@ public Information(decimal value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Bits => As(InformationUnit.Bit); + public decimal Bits => As(InformationUnit.Bit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Bytes => As(InformationUnit.Byte); + public decimal Bytes => As(InformationUnit.Byte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Exabits => As(InformationUnit.Exabit); + public decimal Exabits => As(InformationUnit.Exabit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Exabytes => As(InformationUnit.Exabyte); + public decimal Exabytes => As(InformationUnit.Exabyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Exbibits => As(InformationUnit.Exbibit); + public decimal Exbibits => As(InformationUnit.Exbibit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Exbibytes => As(InformationUnit.Exbibyte); + public decimal Exbibytes => As(InformationUnit.Exbibyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Gibibits => As(InformationUnit.Gibibit); + public decimal Gibibits => As(InformationUnit.Gibibit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Gibibytes => As(InformationUnit.Gibibyte); + public decimal Gibibytes => As(InformationUnit.Gibibyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Gigabits => As(InformationUnit.Gigabit); + public decimal Gigabits => As(InformationUnit.Gigabit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Gigabytes => As(InformationUnit.Gigabyte); + public decimal Gigabytes => As(InformationUnit.Gigabyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Kibibits => As(InformationUnit.Kibibit); + public decimal Kibibits => As(InformationUnit.Kibibit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Kibibytes => As(InformationUnit.Kibibyte); + public decimal Kibibytes => As(InformationUnit.Kibibyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Kilobits => As(InformationUnit.Kilobit); + public decimal Kilobits => As(InformationUnit.Kilobit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Kilobytes => As(InformationUnit.Kilobyte); + public decimal Kilobytes => As(InformationUnit.Kilobyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Mebibits => As(InformationUnit.Mebibit); + public decimal Mebibits => As(InformationUnit.Mebibit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Mebibytes => As(InformationUnit.Mebibyte); + public decimal Mebibytes => As(InformationUnit.Mebibyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Megabits => As(InformationUnit.Megabit); + public decimal Megabits => As(InformationUnit.Megabit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Megabytes => As(InformationUnit.Megabyte); + public decimal Megabytes => As(InformationUnit.Megabyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Pebibits => As(InformationUnit.Pebibit); + public decimal Pebibits => As(InformationUnit.Pebibit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Pebibytes => As(InformationUnit.Pebibyte); + public decimal Pebibytes => As(InformationUnit.Pebibyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Petabits => As(InformationUnit.Petabit); + public decimal Petabits => As(InformationUnit.Petabit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Petabytes => As(InformationUnit.Petabyte); + public decimal Petabytes => As(InformationUnit.Petabyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Tebibits => As(InformationUnit.Tebibit); + public decimal Tebibits => As(InformationUnit.Tebibit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Tebibytes => As(InformationUnit.Tebibyte); + public decimal Tebibytes => As(InformationUnit.Tebibyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Terabits => As(InformationUnit.Terabit); + public decimal Terabits => As(InformationUnit.Terabit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Terabytes => As(InformationUnit.Terabyte); + public decimal Terabytes => As(InformationUnit.Terabyte); #endregion @@ -895,7 +896,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Infor } /// Get ratio value from dividing by . - public static double operator /(Information left, Information right) + public static decimal operator /(Information left, Information right) { return left.Bits / right.Bits; } @@ -983,13 +984,13 @@ public int CompareTo(Information other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Information other, double tolerance, ComparisonType comparisonType) + public bool Equals(Information other, decimal 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); + decimal thisValue = this.Value; + decimal otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1011,17 +1012,21 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(InformationUnit unit) + public decimal As(InformationUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; + + return GetValueAs(unit); + } - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + double IQuantity.As(InformationUnit unit) + { + return (double)As(unit); } /// - public double As(UnitSystem unitSystem) + public decimal As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1035,13 +1040,19 @@ public double As(UnitSystem unitSystem) return As(firstUnitInfo.Value); } + /// + double IQuantity.As(UnitSystem unitSystem) + { + return (double)As(unitSystem); + } + /// double IQuantity.As(Enum unit) { - if (!(unit is InformationUnit unitAsInformationUnit)) + if (!(unit is InformationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(InformationUnit)} is supported.", nameof(unit)); - return As(unitAsInformationUnit); + return (double)As(typedUnit); } /// @@ -1088,10 +1099,10 @@ public Information ToUnit(InformationUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is InformationUnit unitAsInformationUnit)) + if (!(unit is InformationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(InformationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsInformationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index f395d39318..f868a9e832 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -149,6 +149,9 @@ public Irradiance(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -755,7 +758,7 @@ public bool Equals(Irradiance other, double tolerance, ComparisonType comparison if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -781,10 +784,9 @@ public override int GetHashCode() public double As(IrradianceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -805,10 +807,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is IrradianceUnit unitAsIrradianceUnit)) + if (!(unit is IrradianceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradianceUnit)} is supported.", nameof(unit)); - return As(unitAsIrradianceUnit); + return (double)As(typedUnit); } /// @@ -855,10 +857,10 @@ public Irradiance ToUnit(IrradianceUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is IrradianceUnit unitAsIrradianceUnit)) + if (!(unit is IrradianceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradianceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsIrradianceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index 9ddd5731b6..adbc7282a4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -145,6 +145,9 @@ public Irradiation(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -625,7 +628,7 @@ public bool Equals(Irradiation other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -651,10 +654,9 @@ public override int GetHashCode() public double As(IrradiationUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -675,10 +677,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is IrradiationUnit unitAsIrradiationUnit)) + if (!(unit is IrradiationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradiationUnit)} is supported.", nameof(unit)); - return As(unitAsIrradiationUnit); + return (double)As(typedUnit); } /// @@ -725,10 +727,10 @@ public Irradiation ToUnit(IrradiationUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is IrradiationUnit unitAsIrradiationUnit)) + if (!(unit is IrradiationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradiationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsIrradiationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs index 7c5b0cee06..fc85e8048b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs @@ -146,6 +146,9 @@ public Jerk(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -709,7 +712,7 @@ public bool Equals(Jerk 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 thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -735,10 +738,9 @@ public override int GetHashCode() public double As(JerkUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -759,10 +761,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is JerkUnit unitAsJerkUnit)) + if (!(unit is JerkUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(JerkUnit)} is supported.", nameof(unit)); - return As(unitAsJerkUnit); + return (double)As(typedUnit); } /// @@ -809,10 +811,10 @@ public Jerk ToUnit(JerkUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is JerkUnit unitAsJerkUnit)) + if (!(unit is JerkUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(JerkUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsJerkUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 35282f2c29..d2a91cd9e1 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -147,6 +147,9 @@ public KinematicViscosity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -671,7 +674,7 @@ public bool Equals(KinematicViscosity other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -697,10 +700,9 @@ public override int GetHashCode() public double As(KinematicViscosityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -721,10 +723,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is KinematicViscosityUnit unitAsKinematicViscosityUnit)) + if (!(unit is KinematicViscosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(KinematicViscosityUnit)} is supported.", nameof(unit)); - return As(unitAsKinematicViscosityUnit); + return (double)As(typedUnit); } /// @@ -771,10 +773,10 @@ public KinematicViscosity ToUnit(KinematicViscosityUnit unit, UnitConverter unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is KinematicViscosityUnit unitAsKinematicViscosityUnit)) + if (!(unit is KinematicViscosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(KinematicViscosityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsKinematicViscosityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs index fa9e8077ee..02e4f6c610 100644 --- a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs @@ -137,6 +137,9 @@ public LapseRate(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -509,7 +512,7 @@ public bool Equals(LapseRate other, double tolerance, ComparisonType comparisonT if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -535,10 +538,9 @@ public override int GetHashCode() public double As(LapseRateUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -559,10 +561,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is LapseRateUnit unitAsLapseRateUnit)) + if (!(unit is LapseRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LapseRateUnit)} is supported.", nameof(unit)); - return As(unitAsLapseRateUnit); + return (double)As(typedUnit); } /// @@ -609,10 +611,10 @@ public LapseRate ToUnit(LapseRateUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LapseRateUnit unitAsLapseRateUnit)) + if (!(unit is LapseRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LapseRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLapseRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index ab1960b463..c1196e3f9b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -171,6 +171,9 @@ public Length(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1205,7 +1208,7 @@ public bool Equals(Length 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 thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1231,10 +1234,9 @@ public override int GetHashCode() public double As(LengthUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1255,10 +1257,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is LengthUnit unitAsLengthUnit)) + if (!(unit is LengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LengthUnit)} is supported.", nameof(unit)); - return As(unitAsLengthUnit); + return (double)As(typedUnit); } /// @@ -1305,10 +1307,10 @@ public Length ToUnit(LengthUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LengthUnit unitAsLengthUnit)) + if (!(unit is LengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LengthUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLengthUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index 16b78f3430..b8d63c8ab6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -137,6 +137,9 @@ public Level(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -535,7 +538,7 @@ public bool Equals(Level 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 thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -561,10 +564,9 @@ public override int GetHashCode() public double As(LevelUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -585,10 +587,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is LevelUnit unitAsLevelUnit)) + if (!(unit is LevelUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LevelUnit)} is supported.", nameof(unit)); - return As(unitAsLevelUnit); + return (double)As(typedUnit); } /// @@ -635,10 +637,10 @@ public Level ToUnit(LevelUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LevelUnit unitAsLevelUnit)) + if (!(unit is LevelUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LevelUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLevelUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 659ad66f37..9007229079 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -152,6 +152,9 @@ public LinearDensity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -758,7 +761,7 @@ public bool Equals(LinearDensity other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -784,10 +787,9 @@ public override int GetHashCode() public double As(LinearDensityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -808,10 +810,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is LinearDensityUnit unitAsLinearDensityUnit)) + if (!(unit is LinearDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearDensityUnit)} is supported.", nameof(unit)); - return As(unitAsLinearDensityUnit); + return (double)As(typedUnit); } /// @@ -858,10 +860,10 @@ public LinearDensity ToUnit(LinearDensityUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LinearDensityUnit unitAsLinearDensityUnit)) + if (!(unit is LinearDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLinearDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index 20a484724a..aac661bd04 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -163,6 +163,9 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -967,7 +970,7 @@ public bool Equals(LinearPowerDensity other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -993,10 +996,9 @@ public override int GetHashCode() public double As(LinearPowerDensityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1017,10 +1019,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is LinearPowerDensityUnit unitAsLinearPowerDensityUnit)) + if (!(unit is LinearPowerDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearPowerDensityUnit)} is supported.", nameof(unit)); - return As(unitAsLinearPowerDensityUnit); + return (double)As(typedUnit); } /// @@ -1067,10 +1069,10 @@ public LinearPowerDensity ToUnit(LinearPowerDensityUnit unit, UnitConverter unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LinearPowerDensityUnit unitAsLinearPowerDensityUnit)) + if (!(unit is LinearPowerDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearPowerDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLinearPowerDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index d78acbfd8c..b81eeb8563 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -152,6 +152,9 @@ public Luminosity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -758,7 +761,7 @@ public bool Equals(Luminosity other, double tolerance, ComparisonType comparison if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -784,10 +787,9 @@ public override int GetHashCode() public double As(LuminosityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -808,10 +810,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is LuminosityUnit unitAsLuminosityUnit)) + if (!(unit is LuminosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminosityUnit)} is supported.", nameof(unit)); - return As(unitAsLuminosityUnit); + return (double)As(typedUnit); } /// @@ -858,10 +860,10 @@ public Luminosity ToUnit(LuminosityUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LuminosityUnit unitAsLuminosityUnit)) + if (!(unit is LuminosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminosityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLuminosityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index debe7b5dd7..e2f0fd7e70 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -139,6 +139,9 @@ public LuminousFlux(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(LuminousFlux other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(LuminousFluxUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is LuminousFluxUnit unitAsLuminousFluxUnit)) + if (!(unit is LuminousFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousFluxUnit)} is supported.", nameof(unit)); - return As(unitAsLuminousFluxUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public LuminousFlux ToUnit(LuminousFluxUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LuminousFluxUnit unitAsLuminousFluxUnit)) + if (!(unit is LuminousFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousFluxUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLuminousFluxUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index 82199274f5..b9646d2046 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -139,6 +139,9 @@ public LuminousIntensity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(LuminousIntensity other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(LuminousIntensityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is LuminousIntensityUnit unitAsLuminousIntensityUnit)) + if (!(unit is LuminousIntensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousIntensityUnit)} is supported.", nameof(unit)); - return As(unitAsLuminousIntensityUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public LuminousIntensity ToUnit(LuminousIntensityUnit unit, UnitConverter unitCo /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LuminousIntensityUnit unitAsLuminousIntensityUnit)) + if (!(unit is LuminousIntensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousIntensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLuminousIntensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index 6103ff0bc9..6455bad9b0 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -144,6 +144,9 @@ public MagneticField(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -606,7 +609,7 @@ public bool Equals(MagneticField other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -632,10 +635,9 @@ public override int GetHashCode() public double As(MagneticFieldUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -656,10 +658,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MagneticFieldUnit unitAsMagneticFieldUnit)) + if (!(unit is MagneticFieldUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFieldUnit)} is supported.", nameof(unit)); - return As(unitAsMagneticFieldUnit); + return (double)As(typedUnit); } /// @@ -706,10 +708,10 @@ public MagneticField ToUnit(MagneticFieldUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MagneticFieldUnit unitAsMagneticFieldUnit)) + if (!(unit is MagneticFieldUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFieldUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMagneticFieldUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index 4be6d9f2f7..2b49eab329 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -139,6 +139,9 @@ public MagneticFlux(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(MagneticFlux other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(MagneticFluxUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MagneticFluxUnit unitAsMagneticFluxUnit)) + if (!(unit is MagneticFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFluxUnit)} is supported.", nameof(unit)); - return As(unitAsMagneticFluxUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public MagneticFlux ToUnit(MagneticFluxUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MagneticFluxUnit unitAsMagneticFluxUnit)) + if (!(unit is MagneticFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFluxUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMagneticFluxUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index f9a7bc0f03..18b3dd108b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -139,6 +139,9 @@ public Magnetization(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(Magnetization other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(MagnetizationUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MagnetizationUnit unitAsMagnetizationUnit)) + if (!(unit is MagnetizationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagnetizationUnit)} is supported.", nameof(unit)); - return As(unitAsMagnetizationUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public Magnetization ToUnit(MagnetizationUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MagnetizationUnit unitAsMagnetizationUnit)) + if (!(unit is MagnetizationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagnetizationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMagnetizationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index 16ecf48781..5e9c02fd49 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -160,6 +160,9 @@ public Mass(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -999,7 +1002,7 @@ public bool Equals(Mass 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 thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1025,10 +1028,9 @@ public override int GetHashCode() public double As(MassUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1049,10 +1051,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MassUnit unitAsMassUnit)) + if (!(unit is MassUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassUnit)} is supported.", nameof(unit)); - return As(unitAsMassUnit); + return (double)As(typedUnit); } /// @@ -1099,10 +1101,10 @@ public Mass ToUnit(MassUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassUnit unitAsMassUnit)) + if (!(unit is MassUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMassUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index 4e0adad314..a8d33a90bc 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -187,6 +187,9 @@ public MassConcentration(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1427,7 +1430,7 @@ public bool Equals(MassConcentration other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1453,10 +1456,9 @@ public override int GetHashCode() public double As(MassConcentrationUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1477,10 +1479,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MassConcentrationUnit unitAsMassConcentrationUnit)) + if (!(unit is MassConcentrationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassConcentrationUnit)} is supported.", nameof(unit)); - return As(unitAsMassConcentrationUnit); + return (double)As(typedUnit); } /// @@ -1527,10 +1529,10 @@ public MassConcentration ToUnit(MassConcentrationUnit unit, UnitConverter unitCo /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassConcentrationUnit unitAsMassConcentrationUnit)) + if (!(unit is MassConcentrationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassConcentrationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMassConcentrationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 30ce043051..cc6418a0a0 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -168,6 +168,9 @@ public MassFlow(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1118,7 +1121,7 @@ public bool Equals(MassFlow other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1144,10 +1147,9 @@ public override int GetHashCode() public double As(MassFlowUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1168,10 +1170,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MassFlowUnit unitAsMassFlowUnit)) + if (!(unit is MassFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFlowUnit)} is supported.", nameof(unit)); - return As(unitAsMassFlowUnit); + return (double)As(typedUnit); } /// @@ -1218,10 +1220,10 @@ public MassFlow ToUnit(MassFlowUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassFlowUnit unitAsMassFlowUnit)) + if (!(unit is MassFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFlowUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMassFlowUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index 48a6bb8a9a..6d64852955 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -147,6 +147,9 @@ public MassFlux(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -717,7 +720,7 @@ public bool Equals(MassFlux other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -743,10 +746,9 @@ public override int GetHashCode() public double As(MassFluxUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -767,10 +769,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MassFluxUnit unitAsMassFluxUnit)) + if (!(unit is MassFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFluxUnit)} is supported.", nameof(unit)); - return As(unitAsMassFluxUnit); + return (double)As(typedUnit); } /// @@ -817,10 +819,10 @@ public MassFlux ToUnit(MassFluxUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassFluxUnit unitAsMassFluxUnit)) + if (!(unit is MassFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFluxUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMassFluxUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 2f4b8fe473..5974bbf5bf 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -162,6 +162,9 @@ public MassFraction(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -948,7 +951,7 @@ public bool Equals(MassFraction other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -974,10 +977,9 @@ public override int GetHashCode() public double As(MassFractionUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -998,10 +1000,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MassFractionUnit unitAsMassFractionUnit)) + if (!(unit is MassFractionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFractionUnit)} is supported.", nameof(unit)); - return As(unitAsMassFractionUnit); + return (double)As(typedUnit); } /// @@ -1048,10 +1050,10 @@ public MassFraction ToUnit(MassFractionUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassFractionUnit unitAsMassFractionUnit)) + if (!(unit is MassFractionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFractionUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMassFractionUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 50edc3fea1..f448596381 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -163,6 +163,9 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1021,7 +1024,7 @@ public bool Equals(MassMomentOfInertia other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1047,10 +1050,9 @@ public override int GetHashCode() public double As(MassMomentOfInertiaUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1071,10 +1073,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MassMomentOfInertiaUnit unitAsMassMomentOfInertiaUnit)) + if (!(unit is MassMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassMomentOfInertiaUnit)} is supported.", nameof(unit)); - return As(unitAsMassMomentOfInertiaUnit); + return (double)As(typedUnit); } /// @@ -1121,10 +1123,10 @@ public MassMomentOfInertia ToUnit(MassMomentOfInertiaUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassMomentOfInertiaUnit unitAsMassMomentOfInertiaUnit)) + if (!(unit is MassMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassMomentOfInertiaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMassMomentOfInertiaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index 3b11d29f12..cb779f6d62 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -138,6 +138,9 @@ public MolarEnergy(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -546,7 +549,7 @@ public bool Equals(MolarEnergy other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -572,10 +575,9 @@ public override int GetHashCode() public double As(MolarEnergyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -596,10 +598,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MolarEnergyUnit unitAsMolarEnergyUnit)) + if (!(unit is MolarEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEnergyUnit)} is supported.", nameof(unit)); - return As(unitAsMolarEnergyUnit); + return (double)As(typedUnit); } /// @@ -646,10 +648,10 @@ public MolarEnergy ToUnit(MolarEnergyUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MolarEnergyUnit unitAsMolarEnergyUnit)) + if (!(unit is MolarEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEnergyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMolarEnergyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index 857fcdaf4a..81ce32d495 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -138,6 +138,9 @@ public MolarEntropy(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -546,7 +549,7 @@ public bool Equals(MolarEntropy other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -572,10 +575,9 @@ public override int GetHashCode() public double As(MolarEntropyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -596,10 +598,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MolarEntropyUnit unitAsMolarEntropyUnit)) + if (!(unit is MolarEntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEntropyUnit)} is supported.", nameof(unit)); - return As(unitAsMolarEntropyUnit); + return (double)As(typedUnit); } /// @@ -646,10 +648,10 @@ public MolarEntropy ToUnit(MolarEntropyUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MolarEntropyUnit unitAsMolarEntropyUnit)) + if (!(unit is MolarEntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEntropyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMolarEntropyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 1bc540caa7..271c5a5113 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -147,6 +147,9 @@ public MolarMass(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -729,7 +732,7 @@ public bool Equals(MolarMass other, double tolerance, ComparisonType comparisonT if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -755,10 +758,9 @@ public override int GetHashCode() public double As(MolarMassUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -779,10 +781,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MolarMassUnit unitAsMolarMassUnit)) + if (!(unit is MolarMassUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarMassUnit)} is supported.", nameof(unit)); - return As(unitAsMolarMassUnit); + return (double)As(typedUnit); } /// @@ -829,10 +831,10 @@ public MolarMass ToUnit(MolarMassUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MolarMassUnit unitAsMolarMassUnit)) + if (!(unit is MolarMassUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarMassUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMolarMassUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index 0403f2c28f..8f54f0fffe 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -155,6 +155,9 @@ public Molarity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -695,7 +698,7 @@ public bool Equals(Molarity other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -721,10 +724,9 @@ public override int GetHashCode() public double As(MolarityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -745,10 +747,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MolarityUnit unitAsMolarityUnit)) + if (!(unit is MolarityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarityUnit)} is supported.", nameof(unit)); - return As(unitAsMolarityUnit); + return (double)As(typedUnit); } /// @@ -795,10 +797,10 @@ public Molarity ToUnit(MolarityUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MolarityUnit unitAsMolarityUnit)) + if (!(unit is MolarityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMolarityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index 8f4f597901..59a4be428f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -139,6 +139,9 @@ public Permeability(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(Permeability other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(PermeabilityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is PermeabilityUnit unitAsPermeabilityUnit)) + if (!(unit is PermeabilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermeabilityUnit)} is supported.", nameof(unit)); - return As(unitAsPermeabilityUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public Permeability ToUnit(PermeabilityUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PermeabilityUnit unitAsPermeabilityUnit)) + if (!(unit is PermeabilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermeabilityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPermeabilityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index a375f49800..b946e54c6c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -139,6 +139,9 @@ public Permittivity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(Permittivity other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(PermittivityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is PermittivityUnit unitAsPermittivityUnit)) + if (!(unit is PermittivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermittivityUnit)} is supported.", nameof(unit)); - return As(unitAsPermittivityUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public Permittivity ToUnit(PermittivityUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PermittivityUnit unitAsPermittivityUnit)) + if (!(unit is PermittivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermittivityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPermittivityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs index 3bf7765d64..6281deb4e6 100644 --- a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs @@ -143,6 +143,9 @@ public PorousMediumPermeability(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -587,7 +590,7 @@ public bool Equals(PorousMediumPermeability other, double tolerance, ComparisonT if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -613,10 +616,9 @@ public override int GetHashCode() public double As(PorousMediumPermeabilityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -637,10 +639,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is PorousMediumPermeabilityUnit unitAsPorousMediumPermeabilityUnit)) + if (!(unit is PorousMediumPermeabilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PorousMediumPermeabilityUnit)} is supported.", nameof(unit)); - return As(unitAsPorousMediumPermeabilityUnit); + return (double)As(typedUnit); } /// @@ -687,10 +689,10 @@ public PorousMediumPermeability ToUnit(PorousMediumPermeabilityUnit unit, UnitCo /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PorousMediumPermeabilityUnit unitAsPorousMediumPermeabilityUnit)) + if (!(unit is PorousMediumPermeabilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PorousMediumPermeabilityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPorousMediumPermeabilityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index 843092f2dc..20db46edee 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -161,7 +161,8 @@ public Power(decimal value, UnitSystem unitSystem) /// public decimal Value => _value; - double IQuantity.Value => (double) _value; + /// + QuantityValue IQuantity.Value => _value; /// decimal IDecimalQuantity.Value => _value; @@ -187,134 +188,134 @@ public Power(decimal value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double BoilerHorsepower => As(PowerUnit.BoilerHorsepower); + public decimal BoilerHorsepower => As(PowerUnit.BoilerHorsepower); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double BritishThermalUnitsPerHour => As(PowerUnit.BritishThermalUnitPerHour); + public decimal BritishThermalUnitsPerHour => As(PowerUnit.BritishThermalUnitPerHour); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Decawatts => As(PowerUnit.Decawatt); + public decimal Decawatts => As(PowerUnit.Decawatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Deciwatts => As(PowerUnit.Deciwatt); + public decimal Deciwatts => As(PowerUnit.Deciwatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double ElectricalHorsepower => As(PowerUnit.ElectricalHorsepower); + public decimal ElectricalHorsepower => As(PowerUnit.ElectricalHorsepower); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Femtowatts => As(PowerUnit.Femtowatt); + public decimal Femtowatts => As(PowerUnit.Femtowatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double GigajoulesPerHour => As(PowerUnit.GigajoulePerHour); + public decimal GigajoulesPerHour => As(PowerUnit.GigajoulePerHour); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Gigawatts => As(PowerUnit.Gigawatt); + public decimal Gigawatts => As(PowerUnit.Gigawatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double HydraulicHorsepower => As(PowerUnit.HydraulicHorsepower); + public decimal HydraulicHorsepower => As(PowerUnit.HydraulicHorsepower); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double JoulesPerHour => As(PowerUnit.JoulePerHour); + public decimal JoulesPerHour => As(PowerUnit.JoulePerHour); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double KilobritishThermalUnitsPerHour => As(PowerUnit.KilobritishThermalUnitPerHour); + public decimal KilobritishThermalUnitsPerHour => As(PowerUnit.KilobritishThermalUnitPerHour); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double KilojoulesPerHour => As(PowerUnit.KilojoulePerHour); + public decimal KilojoulesPerHour => As(PowerUnit.KilojoulePerHour); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Kilowatts => As(PowerUnit.Kilowatt); + public decimal Kilowatts => As(PowerUnit.Kilowatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MechanicalHorsepower => As(PowerUnit.MechanicalHorsepower); + public decimal MechanicalHorsepower => As(PowerUnit.MechanicalHorsepower); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MegabritishThermalUnitsPerHour => As(PowerUnit.MegabritishThermalUnitPerHour); + public decimal MegabritishThermalUnitsPerHour => As(PowerUnit.MegabritishThermalUnitPerHour); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MegajoulesPerHour => As(PowerUnit.MegajoulePerHour); + public decimal MegajoulesPerHour => As(PowerUnit.MegajoulePerHour); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Megawatts => As(PowerUnit.Megawatt); + public decimal Megawatts => As(PowerUnit.Megawatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MetricHorsepower => As(PowerUnit.MetricHorsepower); + public decimal MetricHorsepower => As(PowerUnit.MetricHorsepower); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Microwatts => As(PowerUnit.Microwatt); + public decimal Microwatts => As(PowerUnit.Microwatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MillijoulesPerHour => As(PowerUnit.MillijoulePerHour); + public decimal MillijoulesPerHour => As(PowerUnit.MillijoulePerHour); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Milliwatts => As(PowerUnit.Milliwatt); + public decimal Milliwatts => As(PowerUnit.Milliwatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Nanowatts => As(PowerUnit.Nanowatt); + public decimal Nanowatts => As(PowerUnit.Nanowatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Petawatts => As(PowerUnit.Petawatt); + public decimal Petawatts => As(PowerUnit.Petawatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Picowatts => As(PowerUnit.Picowatt); + public decimal Picowatts => As(PowerUnit.Picowatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Terawatts => As(PowerUnit.Terawatt); + public decimal Terawatts => As(PowerUnit.Terawatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Watts => As(PowerUnit.Watt); + public decimal Watts => As(PowerUnit.Watt); #endregion @@ -328,7 +329,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> PowerUnit unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.BoilerHorsepower, quantity => new Power(quantity.Value / 9812.5m, PowerUnit.BoilerHorsepower)); - unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.BritishThermalUnitPerHour, quantity => new Power(quantity.Value / 0.293071m, PowerUnit.BritishThermalUnitPerHour)); + unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.BritishThermalUnitPerHour, quantity => new Power(quantity.Value / 0.29307107017m, PowerUnit.BritishThermalUnitPerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Decawatt, quantity => new Power((quantity.Value) / 1e1m, PowerUnit.Decawatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Deciwatt, quantity => new Power((quantity.Value) / 1e-1m, PowerUnit.Deciwatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.ElectricalHorsepower, quantity => new Power(quantity.Value / 746m, PowerUnit.ElectricalHorsepower)); @@ -337,11 +338,11 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Gigawatt, quantity => new Power((quantity.Value) / 1e9m, PowerUnit.Gigawatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.HydraulicHorsepower, quantity => new Power(quantity.Value / 745.69988145m, PowerUnit.HydraulicHorsepower)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.JoulePerHour, quantity => new Power(quantity.Value * 3600m, PowerUnit.JoulePerHour)); - unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.KilobritishThermalUnitPerHour, quantity => new Power((quantity.Value / 0.293071m) / 1e3m, PowerUnit.KilobritishThermalUnitPerHour)); + unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.KilobritishThermalUnitPerHour, quantity => new Power((quantity.Value / 0.29307107017m) / 1e3m, PowerUnit.KilobritishThermalUnitPerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.KilojoulePerHour, quantity => new Power((quantity.Value * 3600m) / 1e3m, PowerUnit.KilojoulePerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Kilowatt, quantity => new Power((quantity.Value) / 1e3m, PowerUnit.Kilowatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MechanicalHorsepower, quantity => new Power(quantity.Value / 745.69m, PowerUnit.MechanicalHorsepower)); - unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MegabritishThermalUnitPerHour, quantity => new Power((quantity.Value / 0.293071m) / 1e6m, PowerUnit.MegabritishThermalUnitPerHour)); + unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MegabritishThermalUnitPerHour, quantity => new Power((quantity.Value / 0.29307107017m) / 1e6m, PowerUnit.MegabritishThermalUnitPerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MegajoulePerHour, quantity => new Power((quantity.Value * 3600m) / 1e6m, PowerUnit.MegajoulePerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Megawatt, quantity => new Power((quantity.Value) / 1e6m, PowerUnit.Megawatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MetricHorsepower, quantity => new Power(quantity.Value / 735.49875m, PowerUnit.MetricHorsepower)); @@ -358,7 +359,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: PowerUnit -> BaseUnit unitConverter.SetConversionFunction(PowerUnit.BoilerHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 9812.5m, PowerUnit.Watt)); - unitConverter.SetConversionFunction(PowerUnit.BritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power(quantity.Value * 0.293071m, PowerUnit.Watt)); + unitConverter.SetConversionFunction(PowerUnit.BritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power(quantity.Value * 0.29307107017m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.Decawatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e1m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.Deciwatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e-1m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.ElectricalHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 746m, PowerUnit.Watt)); @@ -367,11 +368,11 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PowerUnit.Gigawatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e9m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.HydraulicHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 745.69988145m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.JoulePerHour, PowerUnit.Watt, quantity => new Power(quantity.Value / 3600m, PowerUnit.Watt)); - unitConverter.SetConversionFunction(PowerUnit.KilobritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power((quantity.Value * 0.293071m) * 1e3m, PowerUnit.Watt)); + unitConverter.SetConversionFunction(PowerUnit.KilobritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power((quantity.Value * 0.29307107017m) * 1e3m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.KilojoulePerHour, PowerUnit.Watt, quantity => new Power((quantity.Value / 3600m) * 1e3m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.Kilowatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e3m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.MechanicalHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 745.69m, PowerUnit.Watt)); - unitConverter.SetConversionFunction(PowerUnit.MegabritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power((quantity.Value * 0.293071m) * 1e6m, PowerUnit.Watt)); + unitConverter.SetConversionFunction(PowerUnit.MegabritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power((quantity.Value * 0.29307107017m) * 1e6m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.MegajoulePerHour, PowerUnit.Watt, quantity => new Power((quantity.Value / 3600m) * 1e6m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.Megawatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e6m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.MetricHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 735.49875m, PowerUnit.Watt)); @@ -895,7 +896,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power } /// Get ratio value from dividing by . - public static double operator /(Power left, Power right) + public static decimal operator /(Power left, Power right) { return left.Watts / right.Watts; } @@ -983,13 +984,13 @@ public int CompareTo(Power other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Power other, double tolerance, ComparisonType comparisonType) + public bool Equals(Power other, decimal 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); + decimal thisValue = this.Value; + decimal otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1011,17 +1012,21 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PowerUnit unit) + public decimal As(PowerUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; + + return GetValueAs(unit); + } - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + double IQuantity.As(PowerUnit unit) + { + return (double)As(unit); } /// - public double As(UnitSystem unitSystem) + public decimal As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1035,13 +1040,19 @@ public double As(UnitSystem unitSystem) return As(firstUnitInfo.Value); } + /// + double IQuantity.As(UnitSystem unitSystem) + { + return (double)As(unitSystem); + } + /// double IQuantity.As(Enum unit) { - if (!(unit is PowerUnit unitAsPowerUnit)) + if (!(unit is PowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerUnit)} is supported.", nameof(unit)); - return As(unitAsPowerUnit); + return (double)As(typedUnit); } /// @@ -1088,10 +1099,10 @@ public Power ToUnit(PowerUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PowerUnit unitAsPowerUnit)) + if (!(unit is PowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPowerUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index a13b01eef5..203f70848c 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -179,6 +179,9 @@ public PowerDensity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1325,7 +1328,7 @@ public bool Equals(PowerDensity other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1351,10 +1354,9 @@ public override int GetHashCode() public double As(PowerDensityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1375,10 +1377,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is PowerDensityUnit unitAsPowerDensityUnit)) + if (!(unit is PowerDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerDensityUnit)} is supported.", nameof(unit)); - return As(unitAsPowerDensityUnit); + return (double)As(typedUnit); } /// @@ -1425,10 +1427,10 @@ public PowerDensity ToUnit(PowerDensityUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PowerDensityUnit unitAsPowerDensityUnit)) + if (!(unit is PowerDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPowerDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index e2297bd8ec..d04c12a898 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -137,6 +137,9 @@ public PowerRatio(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -535,7 +538,7 @@ public bool Equals(PowerRatio other, double tolerance, ComparisonType comparison if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -561,10 +564,9 @@ public override int GetHashCode() public double As(PowerRatioUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -585,10 +587,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is PowerRatioUnit unitAsPowerRatioUnit)) + if (!(unit is PowerRatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerRatioUnit)} is supported.", nameof(unit)); - return As(unitAsPowerRatioUnit); + return (double)As(typedUnit); } /// @@ -635,10 +637,10 @@ public PowerRatio ToUnit(PowerRatioUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PowerRatioUnit unitAsPowerRatioUnit)) + if (!(unit is PowerRatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerRatioUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPowerRatioUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index 12ab6f58c5..96f98ab024 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -182,6 +182,9 @@ public Pressure(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1413,7 +1416,7 @@ public bool Equals(Pressure other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1439,10 +1442,9 @@ public override int GetHashCode() public double As(PressureUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1463,10 +1465,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is PressureUnit unitAsPressureUnit)) + if (!(unit is PressureUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureUnit)} is supported.", nameof(unit)); - return As(unitAsPressureUnit); + return (double)As(typedUnit); } /// @@ -1513,10 +1515,10 @@ public Pressure ToUnit(PressureUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PressureUnit unitAsPressureUnit)) + if (!(unit is PressureUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPressureUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index 7ee7d7f344..0f4f5c9cbd 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -149,6 +149,9 @@ public PressureChangeRate(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -769,7 +772,7 @@ public bool Equals(PressureChangeRate other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -795,10 +798,9 @@ public override int GetHashCode() public double As(PressureChangeRateUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -819,10 +821,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is PressureChangeRateUnit unitAsPressureChangeRateUnit)) + if (!(unit is PressureChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsPressureChangeRateUnit); + return (double)As(typedUnit); } /// @@ -869,10 +871,10 @@ public PressureChangeRate ToUnit(PressureChangeRateUnit unit, UnitConverter unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PressureChangeRateUnit unitAsPressureChangeRateUnit)) + if (!(unit is PressureChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPressureChangeRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index 4477fbdf39..792448e7b3 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -141,6 +141,9 @@ public Ratio(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -603,7 +606,7 @@ public bool Equals(Ratio 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 thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -629,10 +632,9 @@ public override int GetHashCode() public double As(RatioUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -653,10 +655,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is RatioUnit unitAsRatioUnit)) + if (!(unit is RatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioUnit)} is supported.", nameof(unit)); - return As(unitAsRatioUnit); + return (double)As(typedUnit); } /// @@ -703,10 +705,10 @@ public Ratio ToUnit(RatioUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RatioUnit unitAsRatioUnit)) + if (!(unit is RatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRatioUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index 9a19832e06..bb1d5c85d5 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -137,6 +137,9 @@ public RatioChangeRate(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -527,7 +530,7 @@ public bool Equals(RatioChangeRate other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -553,10 +556,9 @@ public override int GetHashCode() public double As(RatioChangeRateUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -577,10 +579,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is RatioChangeRateUnit unitAsRatioChangeRateUnit)) + if (!(unit is RatioChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsRatioChangeRateUnit); + return (double)As(typedUnit); } /// @@ -627,10 +629,10 @@ public RatioChangeRate ToUnit(RatioChangeRateUnit unit, UnitConverter unitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RatioChangeRateUnit unitAsRatioChangeRateUnit)) + if (!(unit is RatioChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRatioChangeRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index b46c2e5303..74233fc07e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -138,6 +138,9 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -546,7 +549,7 @@ public bool Equals(ReactiveEnergy other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -572,10 +575,9 @@ public override int GetHashCode() public double As(ReactiveEnergyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -596,10 +598,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ReactiveEnergyUnit unitAsReactiveEnergyUnit)) + if (!(unit is ReactiveEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactiveEnergyUnit)} is supported.", nameof(unit)); - return As(unitAsReactiveEnergyUnit); + return (double)As(typedUnit); } /// @@ -646,10 +648,10 @@ public ReactiveEnergy ToUnit(ReactiveEnergyUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ReactiveEnergyUnit unitAsReactiveEnergyUnit)) + if (!(unit is ReactiveEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactiveEnergyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsReactiveEnergyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index 12ba60dcba..351dbd214e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -139,6 +139,9 @@ public ReactivePower(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -565,7 +568,7 @@ public bool Equals(ReactivePower other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -591,10 +594,9 @@ public override int GetHashCode() public double As(ReactivePowerUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -615,10 +617,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ReactivePowerUnit unitAsReactivePowerUnit)) + if (!(unit is ReactivePowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactivePowerUnit)} is supported.", nameof(unit)); - return As(unitAsReactivePowerUnit); + return (double)As(typedUnit); } /// @@ -665,10 +667,10 @@ public ReactivePower ToUnit(ReactivePowerUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ReactivePowerUnit unitAsReactivePowerUnit)) + if (!(unit is ReactivePowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactivePowerUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsReactivePowerUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index fa18c54017..80fc416a3f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -149,6 +149,9 @@ public ReciprocalArea(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -701,7 +704,7 @@ public bool Equals(ReciprocalArea other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -727,10 +730,9 @@ public override int GetHashCode() public double As(ReciprocalAreaUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -751,10 +753,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ReciprocalAreaUnit unitAsReciprocalAreaUnit)) + if (!(unit is ReciprocalAreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalAreaUnit)} is supported.", nameof(unit)); - return As(unitAsReciprocalAreaUnit); + return (double)As(typedUnit); } /// @@ -801,10 +803,10 @@ public ReciprocalArea ToUnit(ReciprocalAreaUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ReciprocalAreaUnit unitAsReciprocalAreaUnit)) + if (!(unit is ReciprocalAreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalAreaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsReciprocalAreaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index db5125af45..9293599a58 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -148,6 +148,9 @@ public ReciprocalLength(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -682,7 +685,7 @@ public bool Equals(ReciprocalLength other, double tolerance, ComparisonType comp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -708,10 +711,9 @@ public override int GetHashCode() public double As(ReciprocalLengthUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -732,10 +734,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ReciprocalLengthUnit unitAsReciprocalLengthUnit)) + if (!(unit is ReciprocalLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalLengthUnit)} is supported.", nameof(unit)); - return As(unitAsReciprocalLengthUnit); + return (double)As(typedUnit); } /// @@ -782,10 +784,10 @@ public ReciprocalLength ToUnit(ReciprocalLengthUnit unit, UnitConverter unitConv /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ReciprocalLengthUnit unitAsReciprocalLengthUnit)) + if (!(unit is ReciprocalLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalLengthUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsReciprocalLengthUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index b91d29a949..cb554e6454 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -136,6 +136,9 @@ public RelativeHumidity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -508,7 +511,7 @@ public bool Equals(RelativeHumidity other, double tolerance, ComparisonType comp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -534,10 +537,9 @@ public override int GetHashCode() public double As(RelativeHumidityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -558,10 +560,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is RelativeHumidityUnit unitAsRelativeHumidityUnit)) + if (!(unit is RelativeHumidityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RelativeHumidityUnit)} is supported.", nameof(unit)); - return As(unitAsRelativeHumidityUnit); + return (double)As(typedUnit); } /// @@ -608,10 +610,10 @@ public RelativeHumidity ToUnit(RelativeHumidityUnit unit, UnitConverter unitConv /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RelativeHumidityUnit unitAsRelativeHumidityUnit)) + if (!(unit is RelativeHumidityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RelativeHumidityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRelativeHumidityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 82e5e89d70..2004f7795d 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -139,6 +139,9 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -565,7 +568,7 @@ public bool Equals(RotationalAcceleration other, double tolerance, ComparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -591,10 +594,9 @@ public override int GetHashCode() public double As(RotationalAccelerationUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -615,10 +617,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is RotationalAccelerationUnit unitAsRotationalAccelerationUnit)) + if (!(unit is RotationalAccelerationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalAccelerationUnit)} is supported.", nameof(unit)); - return As(unitAsRotationalAccelerationUnit); + return (double)As(typedUnit); } /// @@ -665,10 +667,10 @@ public RotationalAcceleration ToUnit(RotationalAccelerationUnit unit, UnitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RotationalAccelerationUnit unitAsRotationalAccelerationUnit)) + if (!(unit is RotationalAccelerationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalAccelerationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRotationalAccelerationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index 85e4e1cff9..d3785cd75e 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -148,6 +148,9 @@ public RotationalSpeed(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -748,7 +751,7 @@ public bool Equals(RotationalSpeed other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -774,10 +777,9 @@ public override int GetHashCode() public double As(RotationalSpeedUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -798,10 +800,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is RotationalSpeedUnit unitAsRotationalSpeedUnit)) + if (!(unit is RotationalSpeedUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalSpeedUnit)} is supported.", nameof(unit)); - return As(unitAsRotationalSpeedUnit); + return (double)As(typedUnit); } /// @@ -848,10 +850,10 @@ public RotationalSpeed ToUnit(RotationalSpeedUnit unit, UnitConverter unitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RotationalSpeedUnit unitAsRotationalSpeedUnit)) + if (!(unit is RotationalSpeedUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalSpeedUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRotationalSpeedUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index dd3526719d..ffa39406f7 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -168,6 +168,9 @@ public RotationalStiffness(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1116,7 +1119,7 @@ public bool Equals(RotationalStiffness other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1142,10 +1145,9 @@ public override int GetHashCode() public double As(RotationalStiffnessUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1166,10 +1168,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is RotationalStiffnessUnit unitAsRotationalStiffnessUnit)) + if (!(unit is RotationalStiffnessUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessUnit)} is supported.", nameof(unit)); - return As(unitAsRotationalStiffnessUnit); + return (double)As(typedUnit); } /// @@ -1216,10 +1218,10 @@ public RotationalStiffness ToUnit(RotationalStiffnessUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RotationalStiffnessUnit unitAsRotationalStiffnessUnit)) + if (!(unit is RotationalStiffnessUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRotationalStiffnessUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 603b45d53a..9b29552a4e 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -140,6 +140,9 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -584,7 +587,7 @@ public bool Equals(RotationalStiffnessPerLength other, double tolerance, Compari if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -610,10 +613,9 @@ public override int GetHashCode() public double As(RotationalStiffnessPerLengthUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -634,10 +636,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is RotationalStiffnessPerLengthUnit unitAsRotationalStiffnessPerLengthUnit)) + if (!(unit is RotationalStiffnessPerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessPerLengthUnit)} is supported.", nameof(unit)); - return As(unitAsRotationalStiffnessPerLengthUnit); + return (double)As(typedUnit); } /// @@ -684,10 +686,10 @@ public RotationalStiffnessPerLength ToUnit(RotationalStiffnessPerLengthUnit unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RotationalStiffnessPerLengthUnit unitAsRotationalStiffnessPerLengthUnit)) + if (!(unit is RotationalStiffnessPerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessPerLengthUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRotationalStiffnessPerLengthUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index 4b70a95229..12bc815bd7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -136,6 +136,9 @@ public Scalar(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -508,7 +511,7 @@ public bool Equals(Scalar 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 thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -534,10 +537,9 @@ public override int GetHashCode() public double As(ScalarUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -558,10 +560,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ScalarUnit unitAsScalarUnit)) + if (!(unit is ScalarUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ScalarUnit)} is supported.", nameof(unit)); - return As(unitAsScalarUnit); + return (double)As(typedUnit); } /// @@ -608,10 +610,10 @@ public Scalar ToUnit(ScalarUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ScalarUnit unitAsScalarUnit)) + if (!(unit is ScalarUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ScalarUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsScalarUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index 9a4b65cb3d..d5deb55d7a 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -139,6 +139,9 @@ public SolidAngle(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(SolidAngle other, double tolerance, ComparisonType comparison if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(SolidAngleUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is SolidAngleUnit unitAsSolidAngleUnit)) + if (!(unit is SolidAngleUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SolidAngleUnit)} is supported.", nameof(unit)); - return As(unitAsSolidAngleUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public SolidAngle ToUnit(SolidAngleUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SolidAngleUnit unitAsSolidAngleUnit)) + if (!(unit is SolidAngleUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SolidAngleUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSolidAngleUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index 454fa20918..8a9ec48aae 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -167,6 +167,9 @@ public SpecificEnergy(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1043,7 +1046,7 @@ public bool Equals(SpecificEnergy other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1069,10 +1072,9 @@ public override int GetHashCode() public double As(SpecificEnergyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1093,10 +1095,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is SpecificEnergyUnit unitAsSpecificEnergyUnit)) + if (!(unit is SpecificEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEnergyUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificEnergyUnit); + return (double)As(typedUnit); } /// @@ -1143,10 +1145,10 @@ public SpecificEnergy ToUnit(SpecificEnergyUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificEnergyUnit unitAsSpecificEnergyUnit)) + if (!(unit is SpecificEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEnergyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSpecificEnergyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index 26c1ea1e6f..952769e807 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -144,6 +144,9 @@ public SpecificEntropy(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -660,7 +663,7 @@ public bool Equals(SpecificEntropy other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -686,10 +689,9 @@ public override int GetHashCode() public double As(SpecificEntropyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -710,10 +712,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is SpecificEntropyUnit unitAsSpecificEntropyUnit)) + if (!(unit is SpecificEntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEntropyUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificEntropyUnit); + return (double)As(typedUnit); } /// @@ -760,10 +762,10 @@ public SpecificEntropy ToUnit(SpecificEntropyUnit unit, UnitConverter unitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificEntropyUnit unitAsSpecificEntropyUnit)) + if (!(unit is SpecificEntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEntropyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSpecificEntropyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index e295f67c8e..1a1e9c4147 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -142,6 +142,9 @@ public SpecificFuelConsumption(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -568,7 +571,7 @@ public bool Equals(SpecificFuelConsumption other, double tolerance, ComparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -594,10 +597,9 @@ public override int GetHashCode() public double As(SpecificFuelConsumptionUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -618,10 +620,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is SpecificFuelConsumptionUnit unitAsSpecificFuelConsumptionUnit)) + if (!(unit is SpecificFuelConsumptionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificFuelConsumptionUnit); + return (double)As(typedUnit); } /// @@ -668,10 +670,10 @@ public SpecificFuelConsumption ToUnit(SpecificFuelConsumptionUnit unit, UnitConv /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificFuelConsumptionUnit unitAsSpecificFuelConsumptionUnit)) + if (!(unit is SpecificFuelConsumptionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSpecificFuelConsumptionUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index f15fc45a52..2f564d7bd7 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -138,6 +138,9 @@ public SpecificVolume(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -546,7 +549,7 @@ public bool Equals(SpecificVolume other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -572,10 +575,9 @@ public override int GetHashCode() public double As(SpecificVolumeUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -596,10 +598,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is SpecificVolumeUnit unitAsSpecificVolumeUnit)) + if (!(unit is SpecificVolumeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificVolumeUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificVolumeUnit); + return (double)As(typedUnit); } /// @@ -646,10 +648,10 @@ public SpecificVolume ToUnit(SpecificVolumeUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificVolumeUnit unitAsSpecificVolumeUnit)) + if (!(unit is SpecificVolumeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificVolumeUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSpecificVolumeUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index 1698dbf5e8..c70b66490f 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -155,6 +155,9 @@ public SpecificWeight(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -815,7 +818,7 @@ public bool Equals(SpecificWeight other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -841,10 +844,9 @@ public override int GetHashCode() public double As(SpecificWeightUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -865,10 +867,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is SpecificWeightUnit unitAsSpecificWeightUnit)) + if (!(unit is SpecificWeightUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificWeightUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificWeightUnit); + return (double)As(typedUnit); } /// @@ -915,10 +917,10 @@ public SpecificWeight ToUnit(SpecificWeightUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificWeightUnit unitAsSpecificWeightUnit)) + if (!(unit is SpecificWeightUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificWeightUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSpecificWeightUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index f064d928b9..fbb92e88d4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -167,6 +167,9 @@ public Speed(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1120,7 +1123,7 @@ public bool Equals(Speed 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 thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1146,10 +1149,9 @@ public override int GetHashCode() public double As(SpeedUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1170,10 +1172,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is SpeedUnit unitAsSpeedUnit)) + if (!(unit is SpeedUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpeedUnit)} is supported.", nameof(unit)); - return As(unitAsSpeedUnit); + return (double)As(typedUnit); } /// @@ -1220,10 +1222,10 @@ public Speed ToUnit(SpeedUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpeedUnit unitAsSpeedUnit)) + if (!(unit is SpeedUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpeedUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSpeedUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 9267650cd1..5d79ef2ed3 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -144,6 +144,9 @@ public StandardVolumeFlow(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -660,7 +663,7 @@ public bool Equals(StandardVolumeFlow other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -686,10 +689,9 @@ public override int GetHashCode() public double As(StandardVolumeFlowUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -710,10 +712,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is StandardVolumeFlowUnit unitAsStandardVolumeFlowUnit)) + if (!(unit is StandardVolumeFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(StandardVolumeFlowUnit)} is supported.", nameof(unit)); - return As(unitAsStandardVolumeFlowUnit); + return (double)As(typedUnit); } /// @@ -760,10 +762,10 @@ public StandardVolumeFlow ToUnit(StandardVolumeFlowUnit unit, UnitConverter unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is StandardVolumeFlowUnit unitAsStandardVolumeFlowUnit)) + if (!(unit is StandardVolumeFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(StandardVolumeFlowUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsStandardVolumeFlowUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index 9b314a7349..68033f0271 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -145,6 +145,9 @@ public Temperature(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -633,7 +636,7 @@ public bool Equals(Temperature other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -659,10 +662,9 @@ public override int GetHashCode() public double As(TemperatureUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -683,10 +685,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is TemperatureUnit unitAsTemperatureUnit)) + if (!(unit is TemperatureUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureUnit)} is supported.", nameof(unit)); - return As(unitAsTemperatureUnit); + return (double)As(typedUnit); } /// @@ -733,10 +735,10 @@ public Temperature ToUnit(TemperatureUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TemperatureUnit unitAsTemperatureUnit)) + if (!(unit is TemperatureUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTemperatureUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 0f3704b67e..ab7d76e659 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -145,6 +145,9 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -679,7 +682,7 @@ public bool Equals(TemperatureChangeRate other, double tolerance, ComparisonType if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -705,10 +708,9 @@ public override int GetHashCode() public double As(TemperatureChangeRateUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -729,10 +731,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is TemperatureChangeRateUnit unitAsTemperatureChangeRateUnit)) + if (!(unit is TemperatureChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsTemperatureChangeRateUnit); + return (double)As(typedUnit); } /// @@ -779,10 +781,10 @@ public TemperatureChangeRate ToUnit(TemperatureChangeRateUnit unit, UnitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TemperatureChangeRateUnit unitAsTemperatureChangeRateUnit)) + if (!(unit is TemperatureChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTemperatureChangeRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 5fb8eaf2ac..2eb92473f1 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -144,6 +144,9 @@ public TemperatureDelta(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -660,7 +663,7 @@ public bool Equals(TemperatureDelta other, double tolerance, ComparisonType comp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -686,10 +689,9 @@ public override int GetHashCode() public double As(TemperatureDeltaUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -710,10 +712,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is TemperatureDeltaUnit unitAsTemperatureDeltaUnit)) + if (!(unit is TemperatureDeltaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureDeltaUnit)} is supported.", nameof(unit)); - return As(unitAsTemperatureDeltaUnit); + return (double)As(typedUnit); } /// @@ -760,10 +762,10 @@ public TemperatureDelta ToUnit(TemperatureDeltaUnit unit, UnitConverter unitConv /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TemperatureDeltaUnit unitAsTemperatureDeltaUnit)) + if (!(unit is TemperatureDeltaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureDeltaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTemperatureDeltaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs index aaff14abca..78120e21e4 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -139,6 +139,9 @@ public TemperatureGradient(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -565,7 +568,7 @@ public bool Equals(TemperatureGradient other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -591,10 +594,9 @@ public override int GetHashCode() public double As(TemperatureGradientUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -615,10 +617,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is TemperatureGradientUnit unitAsTemperatureGradientUnit)) + if (!(unit is TemperatureGradientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureGradientUnit)} is supported.", nameof(unit)); - return As(unitAsTemperatureGradientUnit); + return (double)As(typedUnit); } /// @@ -665,10 +667,10 @@ public TemperatureGradient ToUnit(TemperatureGradientUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TemperatureGradientUnit unitAsTemperatureGradientUnit)) + if (!(unit is TemperatureGradientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureGradientUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTemperatureGradientUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index 0da7968b47..19b7e51a32 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -140,6 +140,9 @@ public ThermalConductivity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -530,7 +533,7 @@ public bool Equals(ThermalConductivity other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -556,10 +559,9 @@ public override int GetHashCode() public double As(ThermalConductivityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -580,10 +582,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ThermalConductivityUnit unitAsThermalConductivityUnit)) + if (!(unit is ThermalConductivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalConductivityUnit)} is supported.", nameof(unit)); - return As(unitAsThermalConductivityUnit); + return (double)As(typedUnit); } /// @@ -630,10 +632,10 @@ public ThermalConductivity ToUnit(ThermalConductivityUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ThermalConductivityUnit unitAsThermalConductivityUnit)) + if (!(unit is ThermalConductivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalConductivityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsThermalConductivityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index 7ab40b994c..bff304295e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -141,6 +141,9 @@ public ThermalResistance(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -603,7 +606,7 @@ public bool Equals(ThermalResistance other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -629,10 +632,9 @@ public override int GetHashCode() public double As(ThermalResistanceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -653,10 +655,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ThermalResistanceUnit unitAsThermalResistanceUnit)) + if (!(unit is ThermalResistanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalResistanceUnit)} is supported.", nameof(unit)); - return As(unitAsThermalResistanceUnit); + return (double)As(typedUnit); } /// @@ -703,10 +705,10 @@ public ThermalResistance ToUnit(ThermalResistanceUnit unit, UnitConverter unitCo /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ThermalResistanceUnit unitAsThermalResistanceUnit)) + if (!(unit is ThermalResistanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalResistanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsThermalResistanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index 2a512729ec..87ab142d53 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -160,6 +160,9 @@ public Torque(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -967,7 +970,7 @@ public bool Equals(Torque 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 thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -993,10 +996,9 @@ public override int GetHashCode() public double As(TorqueUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1017,10 +1019,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is TorqueUnit unitAsTorqueUnit)) + if (!(unit is TorqueUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorqueUnit)} is supported.", nameof(unit)); - return As(unitAsTorqueUnit); + return (double)As(typedUnit); } /// @@ -1067,10 +1069,10 @@ public Torque ToUnit(TorqueUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TorqueUnit unitAsTorqueUnit)) + if (!(unit is TorqueUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorqueUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTorqueUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index 4fd2f5f8ef..b714941438 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -156,6 +156,9 @@ public TorquePerLength(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -891,7 +894,7 @@ public bool Equals(TorquePerLength other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -917,10 +920,9 @@ public override int GetHashCode() public double As(TorquePerLengthUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -941,10 +943,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is TorquePerLengthUnit unitAsTorquePerLengthUnit)) + if (!(unit is TorquePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorquePerLengthUnit)} is supported.", nameof(unit)); - return As(unitAsTorquePerLengthUnit); + return (double)As(typedUnit); } /// @@ -991,10 +993,10 @@ public TorquePerLength ToUnit(TorquePerLengthUnit unit, UnitConverter unitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TorquePerLengthUnit unitAsTorquePerLengthUnit)) + if (!(unit is TorquePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorquePerLengthUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTorquePerLengthUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index f94f7592e1..821bbdbeac 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -139,6 +139,9 @@ public Turbidity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(Turbidity other, double tolerance, ComparisonType comparisonT if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(TurbidityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is TurbidityUnit unitAsTurbidityUnit)) + if (!(unit is TurbidityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TurbidityUnit)} is supported.", nameof(unit)); - return As(unitAsTurbidityUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public Turbidity ToUnit(TurbidityUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TurbidityUnit unitAsTurbidityUnit)) + if (!(unit is TurbidityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TurbidityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTurbidityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index 454db0c919..e90434cf0a 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -136,6 +136,9 @@ public VitaminA(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -508,7 +511,7 @@ public bool Equals(VitaminA other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -534,10 +537,9 @@ public override int GetHashCode() public double As(VitaminAUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -558,10 +560,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is VitaminAUnit unitAsVitaminAUnit)) + if (!(unit is VitaminAUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VitaminAUnit)} is supported.", nameof(unit)); - return As(unitAsVitaminAUnit); + return (double)As(typedUnit); } /// @@ -608,10 +610,10 @@ public VitaminA ToUnit(VitaminAUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VitaminAUnit unitAsVitaminAUnit)) + if (!(unit is VitaminAUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VitaminAUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVitaminAUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 2d54789723..608929c55a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -187,6 +187,9 @@ public Volume(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1524,7 +1527,7 @@ public bool Equals(Volume 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 thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1550,10 +1553,9 @@ public override int GetHashCode() public double As(VolumeUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1574,10 +1576,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is VolumeUnit unitAsVolumeUnit)) + if (!(unit is VolumeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeUnit)} is supported.", nameof(unit)); - return As(unitAsVolumeUnit); + return (double)As(typedUnit); } /// @@ -1624,10 +1626,10 @@ public Volume ToUnit(VolumeUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumeUnit unitAsVolumeUnit)) + if (!(unit is VolumeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVolumeUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 26d1de1beb..0a8c9d086a 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -158,6 +158,9 @@ public VolumeConcentration(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -872,7 +875,7 @@ public bool Equals(VolumeConcentration other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -898,10 +901,9 @@ public override int GetHashCode() public double As(VolumeConcentrationUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -922,10 +924,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is VolumeConcentrationUnit unitAsVolumeConcentrationUnit)) + if (!(unit is VolumeConcentrationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeConcentrationUnit)} is supported.", nameof(unit)); - return As(unitAsVolumeConcentrationUnit); + return (double)As(typedUnit); } /// @@ -972,10 +974,10 @@ public VolumeConcentration ToUnit(VolumeConcentrationUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumeConcentrationUnit unitAsVolumeConcentrationUnit)) + if (!(unit is VolumeConcentrationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeConcentrationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVolumeConcentrationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index 14cecc5941..3094b62967 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -197,6 +197,9 @@ public VolumeFlow(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1694,7 +1697,7 @@ public bool Equals(VolumeFlow other, double tolerance, ComparisonType comparison if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1720,10 +1723,9 @@ public override int GetHashCode() public double As(VolumeFlowUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1744,10 +1746,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is VolumeFlowUnit unitAsVolumeFlowUnit)) + if (!(unit is VolumeFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowUnit)} is supported.", nameof(unit)); - return As(unitAsVolumeFlowUnit); + return (double)As(typedUnit); } /// @@ -1794,10 +1796,10 @@ public VolumeFlow ToUnit(VolumeFlowUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumeFlowUnit unitAsVolumeFlowUnit)) + if (!(unit is VolumeFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVolumeFlowUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs index 93e98d1704..eaf93cc7f5 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs @@ -137,6 +137,9 @@ public VolumeFlowPerArea(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -527,7 +530,7 @@ public bool Equals(VolumeFlowPerArea other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -553,10 +556,9 @@ public override int GetHashCode() public double As(VolumeFlowPerAreaUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -577,10 +579,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is VolumeFlowPerAreaUnit unitAsVolumeFlowPerAreaUnit)) + if (!(unit is VolumeFlowPerAreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowPerAreaUnit)} is supported.", nameof(unit)); - return As(unitAsVolumeFlowPerAreaUnit); + return (double)As(typedUnit); } /// @@ -627,10 +629,10 @@ public VolumeFlowPerArea ToUnit(VolumeFlowPerAreaUnit unit, UnitConverter unitCo /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumeFlowPerAreaUnit unitAsVolumeFlowPerAreaUnit)) + if (!(unit is VolumeFlowPerAreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowPerAreaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVolumeFlowPerAreaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index d07460ee38..875298e59b 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -142,6 +142,9 @@ public VolumePerLength(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -622,7 +625,7 @@ public bool Equals(VolumePerLength other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -648,10 +651,9 @@ public override int GetHashCode() public double As(VolumePerLengthUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -672,10 +674,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is VolumePerLengthUnit unitAsVolumePerLengthUnit)) + if (!(unit is VolumePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumePerLengthUnit)} is supported.", nameof(unit)); - return As(unitAsVolumePerLengthUnit); + return (double)As(typedUnit); } /// @@ -722,10 +724,10 @@ public VolumePerLength ToUnit(VolumePerLengthUnit unit, UnitConverter unitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumePerLengthUnit unitAsVolumePerLengthUnit)) + if (!(unit is VolumePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumePerLengthUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVolumePerLengthUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 3ca758cbc0..883c6b5c7f 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -147,6 +147,9 @@ public VolumetricHeatCapacity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -663,7 +666,7 @@ public bool Equals(VolumetricHeatCapacity other, double tolerance, ComparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -689,10 +692,9 @@ public override int GetHashCode() public double As(VolumetricHeatCapacityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -713,10 +715,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is VolumetricHeatCapacityUnit unitAsVolumetricHeatCapacityUnit)) + if (!(unit is VolumetricHeatCapacityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumetricHeatCapacityUnit)} is supported.", nameof(unit)); - return As(unitAsVolumetricHeatCapacityUnit); + return (double)As(typedUnit); } /// @@ -763,10 +765,10 @@ public VolumetricHeatCapacity ToUnit(VolumetricHeatCapacityUnit unit, UnitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumetricHeatCapacityUnit unitAsVolumetricHeatCapacityUnit)) + if (!(unit is VolumetricHeatCapacityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumetricHeatCapacityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVolumetricHeatCapacityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 2ef276467a..0c4f7e54fc 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -141,6 +141,9 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -603,7 +606,7 @@ public bool Equals(WarpingMomentOfInertia other, double tolerance, ComparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -629,10 +632,9 @@ public override int GetHashCode() public double As(WarpingMomentOfInertiaUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -653,10 +655,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is WarpingMomentOfInertiaUnit unitAsWarpingMomentOfInertiaUnit)) + if (!(unit is WarpingMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(WarpingMomentOfInertiaUnit)} is supported.", nameof(unit)); - return As(unitAsWarpingMomentOfInertiaUnit); + return (double)As(typedUnit); } /// @@ -703,10 +705,10 @@ public WarpingMomentOfInertia ToUnit(WarpingMomentOfInertiaUnit unit, UnitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is WarpingMomentOfInertiaUnit unitAsWarpingMomentOfInertiaUnit)) + if (!(unit is WarpingMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(WarpingMomentOfInertiaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsWarpingMomentOfInertiaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index 48445422fb..92d974c5bc 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -46,7 +46,7 @@ public interface IQuantity : IFormattable /// /// The value this quantity was constructed with. See also . /// - double Value { get; } + QuantityValue Value { get; } /// /// Converts this to an in the given . diff --git a/UnitsNet/QuantityFormatter.cs b/UnitsNet/QuantityFormatter.cs index 8c7fdeb613..6948b14651 100644 --- a/UnitsNet/QuantityFormatter.cs +++ b/UnitsNet/QuantityFormatter.cs @@ -180,8 +180,10 @@ private static string FormatUntrimmed(IQuantity quantity, private static string ToStringWithSignificantDigitsAfterRadix(IQuantity quantity, IFormatProvider formatProvider, int number) where TUnitType : Enum { - string formatForSignificantDigits = UnitFormatter.GetFormat(quantity.Value, number); - object[] formatArgs = UnitFormatter.GetFormatArgs(quantity.Unit, quantity.Value, formatProvider, Enumerable.Empty()); + // When a fixed number of digits after the dot is expected, double and decimal behave the same. + var value = (double)quantity.Value; + string formatForSignificantDigits = UnitFormatter.GetFormat(value, number); + object[] formatArgs = UnitFormatter.GetFormatArgs(quantity.Unit, value, formatProvider, Enumerable.Empty()); return string.Format(formatProvider, formatForSignificantDigits, formatArgs); } } diff --git a/UnitsNet/QuantityValue.cs b/UnitsNet/QuantityValue.cs index d25d184e98..862e9133be 100644 --- a/UnitsNet/QuantityValue.cs +++ b/UnitsNet/QuantityValue.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using System.Runtime.InteropServices; using System.Text; +using System.Globalization; using UnitsNet.InternalHelpers; namespace UnitsNet @@ -28,8 +29,13 @@ namespace UnitsNet /// [StructLayout(LayoutKind.Explicit)] [DebuggerDisplay("{GetDebugRepresentation()}")] - public readonly struct QuantityValue + public readonly struct QuantityValue : IFormattable, IEquatable, IComparable, IComparable { + /// + /// The value 0 + /// + public static readonly QuantityValue Zero = new QuantityValue(0, 0); + /// /// Value assigned when implicitly casting from all numeric types except , since /// has the greatest range. @@ -64,6 +70,25 @@ private QuantityValue(decimal val) : this() Type = UnderlyingDataType.Decimal; } + private QuantityValue(double value, decimal valueDecimal) : this() + { + if (valueDecimal != 0) + { + _decimalValue = valueDecimal; + Type = UnderlyingDataType.Decimal; + } + else + { + _doubleValue = value; + Type = UnderlyingDataType.Double; + } + } + + /// + /// Returns true if the underlying value is stored as a decimal + /// + public bool IsDecimal => Type == UnderlyingDataType.Decimal; + #region To QuantityValue // Prefer double for integer types, since most quantities use that type as of now and @@ -103,11 +128,141 @@ public static explicit operator double(QuantityValue number) /// Explicit cast from to . public static explicit operator decimal(QuantityValue number) => number.Type switch + { + UnderlyingDataType.Decimal => number._decimalValue, + UnderlyingDataType.Double => (decimal)number._doubleValue, + _ => throw new NotImplementedException() + }; + + #endregion + + #region Operators and Comparators + + /// + public override bool Equals(object other) + { + if (other is QuantityValue qv) { - UnderlyingDataType.Decimal => number._decimalValue, - UnderlyingDataType.Double => (decimal)number._doubleValue, - _ => throw new NotImplementedException() - }; + return Equals(qv); + } + + return false; + } + + /// + public override int GetHashCode() + { + if (IsDecimal) + { + return _decimalValue.GetHashCode(); + } + else + { + return _doubleValue.GetHashCode(); + } + } + + /// + /// Performs an equality comparison on two instances of . + /// Note that rounding might occur if the two values don't use the same base type. + /// + /// The value to compare to + /// True on exact equality, false otherwise + public bool Equals(QuantityValue other) + { + return CompareTo(other) == 0; + } + + /// Equality comparator + public static bool operator ==(QuantityValue a, QuantityValue b) + { + return a.CompareTo(b) == 0; + } + + /// Inequality comparator + public static bool operator !=(QuantityValue a, QuantityValue b) + { + return a.CompareTo(b) != 0; + } + + /// + /// Greater-than operator + /// + public static bool operator >(QuantityValue a, QuantityValue b) + { + return a.CompareTo(b) > 0; + } + + /// + /// Less-than operator + /// + public static bool operator <(QuantityValue a, QuantityValue b) + { + return a.CompareTo(b) < 0; + } + + /// + /// Greater-than-or-equal operator + /// + public static bool operator >=(QuantityValue a, QuantityValue b) + { + return a.CompareTo(b) >= 0; + } + + /// + /// Less-than-or-equal operator + /// + public static bool operator <=(QuantityValue a, QuantityValue b) + { + return a.CompareTo(b) <= 0; + } + + /// + public int CompareTo(QuantityValue other) + { + if (IsDecimal && other.IsDecimal) + { + return _decimalValue.CompareTo(other._decimalValue); + } + else if (IsDecimal) + { + return _decimalValue.CompareTo((decimal)other._doubleValue); + } + else if (other.IsDecimal) + { + return ((decimal)_doubleValue).CompareTo(other._decimalValue); + } + else + { + return _doubleValue.CompareTo(other._doubleValue); + } + } + + /// + public int CompareTo(object obj) + { + if (obj is null) throw new ArgumentNullException(nameof(obj)); + if (!(obj is QuantityValue other)) throw new ArgumentException("Expected type QuantityValue.", nameof(obj)); + + return CompareTo(other); + } + + /// + /// Returns the negated value of the operand + /// + /// Value to negate + /// -v + public static QuantityValue operator -(QuantityValue v) + { + if (v.IsDecimal) + { + return new QuantityValue(-v._decimalValue); + } + else + { + return new QuantityValue(-v._doubleValue); + } + } #endregion @@ -133,6 +288,44 @@ private string GetDebugRepresentation() return builder.ToString(); } + /// + /// Returns the string representation of the numeric value, formatted using the given standard numeric format string + /// + /// A standard numeric format string (must be valid for either double or decimal, depending on the base type) + /// The string representation + public string ToString(string format) + { + return ToString(format, CultureInfo.CurrentCulture); + } + + /// + /// Returns the string representation of the numeric value, formatted using the given standard numeric format string + /// + /// The culture to use + /// The string representation + public string ToString(IFormatProvider formatProvider) + { + return ToString(string.Empty, formatProvider); + } + + /// + /// Returns the string representation of the underlying value + /// + /// Standard format specifiers. Because the underlying value can be double or decimal, the meaning can vary + /// Culture specific settings + /// A string representation of the number + public string ToString(string format, IFormatProvider formatProvider) + { + if (IsDecimal) + { + return _decimalValue.ToString(format, formatProvider); + } + else + { + return _doubleValue.ToString(format, formatProvider); + } + } + /// /// Describes the underlying type of a . /// diff --git a/UnitsNet/UnitMath.cs b/UnitsNet/UnitMath.cs index d684c77e66..79707c0b71 100644 --- a/UnitsNet/UnitMath.cs +++ b/UnitsNet/UnitMath.cs @@ -17,7 +17,7 @@ public static class UnitMath /// A quantity with a value, such that 0 ≤ value ≤ . public static TQuantity Abs(this TQuantity value) where TQuantity : IQuantity { - return value.Value >= 0 ? value : (TQuantity) Quantity.From(-value.Value, value.Unit); + return value.Value >= QuantityValue.Zero ? value : (TQuantity) Quantity.From(-value.Value, value.Unit); } /// Computes the sum of a sequence of values. @@ -197,5 +197,25 @@ public static TQuantity Average(this IEnumerable so { return source.Select(selector).Average(unitType); } + + /// + /// Explicitly create a instance from a double + /// + /// The input value + /// An instance of + public static QuantityValue ToQuantityValue(this double value) + { + return value; // Implicit cast + } + + /// + /// Explicitly create a instance from a decimal + /// + /// The input value + /// An instance of + public static QuantityValue ToQuantityValue(this decimal value) + { + return value; // Implicit cast + } } }