From e805d31dfe4ec76ea45fb7752715f35a616cb362 Mon Sep 17 00:00:00 2001 From: Tristan Milnthorp Date: Thu, 9 Mar 2023 11:41:56 -0500 Subject: [PATCH 1/2] ToUnit for IValueQuantity should return IValueQuantity --- .../UnitsNetGen/QuantityGenerator.cs | 12 +++++ .../Quantities/ElectricCharge.g.cs | 20 +++---- .../Units/ElectricChargeUnit.g.cs | 2 +- .../NumberToElectricChargeExtensionsTest.g.cs | 8 +-- .../NumberToElectricChargeExtensions.g.cs | 8 +-- .../TestsBase/ElectricChargeTestsBase.g.cs | 54 +++++++++---------- UnitsNet.Tests/IValueQuantityTests.cs | 28 ++++++++++ .../Quantities/Acceleration.g.cs | 12 +++++ .../Quantities/AmountOfSubstance.g.cs | 12 +++++ .../Quantities/AmplitudeRatio.g.cs | 12 +++++ UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 12 +++++ .../Quantities/ApparentEnergy.g.cs | 12 +++++ .../Quantities/ApparentPower.g.cs | 12 +++++ UnitsNet/GeneratedCode/Quantities/Area.g.cs | 12 +++++ .../GeneratedCode/Quantities/AreaDensity.g.cs | 12 +++++ .../Quantities/AreaMomentOfInertia.g.cs | 12 +++++ .../GeneratedCode/Quantities/BitRate.g.cs | 12 +++++ .../BrakeSpecificFuelConsumption.g.cs | 12 +++++ .../GeneratedCode/Quantities/Capacitance.g.cs | 12 +++++ .../CoefficientOfThermalExpansion.g.cs | 12 +++++ .../Quantities/Compressibility.g.cs | 12 +++++ .../GeneratedCode/Quantities/Density.g.cs | 12 +++++ .../GeneratedCode/Quantities/Duration.g.cs | 12 +++++ .../Quantities/DynamicViscosity.g.cs | 12 +++++ .../Quantities/ElectricAdmittance.g.cs | 12 +++++ .../Quantities/ElectricCharge.g.cs | 48 ++++++++++------- .../Quantities/ElectricChargeDensity.g.cs | 12 +++++ .../Quantities/ElectricConductance.g.cs | 12 +++++ .../Quantities/ElectricConductivity.g.cs | 12 +++++ .../Quantities/ElectricCurrent.g.cs | 12 +++++ .../Quantities/ElectricCurrentDensity.g.cs | 12 +++++ .../Quantities/ElectricCurrentGradient.g.cs | 12 +++++ .../Quantities/ElectricField.g.cs | 12 +++++ .../Quantities/ElectricInductance.g.cs | 12 +++++ .../Quantities/ElectricPotential.g.cs | 12 +++++ .../Quantities/ElectricPotentialAc.g.cs | 12 +++++ .../ElectricPotentialChangeRate.g.cs | 12 +++++ .../Quantities/ElectricPotentialDc.g.cs | 12 +++++ .../Quantities/ElectricResistance.g.cs | 12 +++++ .../Quantities/ElectricResistivity.g.cs | 12 +++++ .../ElectricSurfaceChargeDensity.g.cs | 12 +++++ UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 12 +++++ .../Quantities/EnergyDensity.g.cs | 12 +++++ .../GeneratedCode/Quantities/Entropy.g.cs | 12 +++++ UnitsNet/GeneratedCode/Quantities/Force.g.cs | 12 +++++ .../Quantities/ForceChangeRate.g.cs | 12 +++++ .../Quantities/ForcePerLength.g.cs | 12 +++++ .../GeneratedCode/Quantities/Frequency.g.cs | 12 +++++ .../Quantities/FuelEfficiency.g.cs | 12 +++++ .../GeneratedCode/Quantities/HeatFlux.g.cs | 12 +++++ .../Quantities/HeatTransferCoefficient.g.cs | 12 +++++ .../GeneratedCode/Quantities/Illuminance.g.cs | 12 +++++ .../GeneratedCode/Quantities/Impulse.g.cs | 12 +++++ .../GeneratedCode/Quantities/Information.g.cs | 12 +++++ .../GeneratedCode/Quantities/Irradiance.g.cs | 12 +++++ .../GeneratedCode/Quantities/Irradiation.g.cs | 12 +++++ UnitsNet/GeneratedCode/Quantities/Jerk.g.cs | 12 +++++ .../Quantities/KinematicViscosity.g.cs | 12 +++++ UnitsNet/GeneratedCode/Quantities/Length.g.cs | 12 +++++ UnitsNet/GeneratedCode/Quantities/Level.g.cs | 12 +++++ .../Quantities/LinearDensity.g.cs | 12 +++++ .../Quantities/LinearPowerDensity.g.cs | 12 +++++ .../GeneratedCode/Quantities/Luminance.g.cs | 12 +++++ .../GeneratedCode/Quantities/Luminosity.g.cs | 12 +++++ .../Quantities/LuminousFlux.g.cs | 12 +++++ .../Quantities/LuminousIntensity.g.cs | 12 +++++ .../Quantities/MagneticField.g.cs | 12 +++++ .../Quantities/MagneticFlux.g.cs | 12 +++++ .../Quantities/Magnetization.g.cs | 12 +++++ UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 12 +++++ .../Quantities/MassConcentration.g.cs | 12 +++++ .../GeneratedCode/Quantities/MassFlow.g.cs | 12 +++++ .../GeneratedCode/Quantities/MassFlux.g.cs | 12 +++++ .../Quantities/MassFraction.g.cs | 12 +++++ .../Quantities/MassMomentOfInertia.g.cs | 12 +++++ .../GeneratedCode/Quantities/MolarEnergy.g.cs | 12 +++++ .../Quantities/MolarEntropy.g.cs | 12 +++++ .../GeneratedCode/Quantities/MolarFlow.g.cs | 12 +++++ .../GeneratedCode/Quantities/MolarMass.g.cs | 12 +++++ .../GeneratedCode/Quantities/Molarity.g.cs | 12 +++++ .../Quantities/Permeability.g.cs | 12 +++++ .../Quantities/Permittivity.g.cs | 12 +++++ .../Quantities/PorousMediumPermeability.g.cs | 12 +++++ UnitsNet/GeneratedCode/Quantities/Power.g.cs | 12 +++++ .../Quantities/PowerDensity.g.cs | 12 +++++ .../GeneratedCode/Quantities/PowerRatio.g.cs | 12 +++++ .../GeneratedCode/Quantities/Pressure.g.cs | 12 +++++ .../Quantities/PressureChangeRate.g.cs | 12 +++++ UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 12 +++++ .../Quantities/RatioChangeRate.g.cs | 12 +++++ .../Quantities/ReactiveEnergy.g.cs | 12 +++++ .../Quantities/ReactivePower.g.cs | 12 +++++ .../Quantities/ReciprocalArea.g.cs | 12 +++++ .../Quantities/ReciprocalLength.g.cs | 12 +++++ .../Quantities/RelativeHumidity.g.cs | 12 +++++ .../Quantities/RotationalAcceleration.g.cs | 12 +++++ .../Quantities/RotationalSpeed.g.cs | 12 +++++ .../Quantities/RotationalStiffness.g.cs | 12 +++++ .../RotationalStiffnessPerLength.g.cs | 12 +++++ UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 12 +++++ .../GeneratedCode/Quantities/SolidAngle.g.cs | 12 +++++ .../Quantities/SpecificEnergy.g.cs | 12 +++++ .../Quantities/SpecificEntropy.g.cs | 12 +++++ .../Quantities/SpecificFuelConsumption.g.cs | 12 +++++ .../Quantities/SpecificVolume.g.cs | 12 +++++ .../Quantities/SpecificWeight.g.cs | 12 +++++ UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 12 +++++ .../Quantities/StandardVolumeFlow.g.cs | 12 +++++ .../GeneratedCode/Quantities/Temperature.g.cs | 12 +++++ .../Quantities/TemperatureChangeRate.g.cs | 12 +++++ .../Quantities/TemperatureDelta.g.cs | 12 +++++ .../Quantities/TemperatureGradient.g.cs | 12 +++++ .../Quantities/ThermalConductivity.g.cs | 12 +++++ .../Quantities/ThermalResistance.g.cs | 12 +++++ UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 12 +++++ .../Quantities/TorquePerLength.g.cs | 12 +++++ .../GeneratedCode/Quantities/Turbidity.g.cs | 12 +++++ .../GeneratedCode/Quantities/VitaminA.g.cs | 12 +++++ UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 12 +++++ .../Quantities/VolumeConcentration.g.cs | 12 +++++ .../GeneratedCode/Quantities/VolumeFlow.g.cs | 12 +++++ .../Quantities/VolumeFlowPerArea.g.cs | 12 +++++ .../Quantities/VolumePerLength.g.cs | 12 +++++ .../Quantities/VolumetricHeatCapacity.g.cs | 12 +++++ .../Quantities/WarpingMomentOfInertia.g.cs | 12 +++++ .../Units/ElectricChargeUnit.g.cs | 2 +- UnitsNet/IValueQuantity.cs | 19 +++++++ 127 files changed, 1540 insertions(+), 65 deletions(-) diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index c597b72f08..78a6c9fa59 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -1093,6 +1093,18 @@ IQuantity IQuantity.ToUnit(Enum unit) /// IQuantity<{_unitEnumName}> IQuantity<{_unitEnumName}>.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity<{_quantity.ValueType}> IValueQuantity<{_quantity.ValueType}>.ToUnit(Enum unit) + {{ + if (unit is not {_unitEnumName} typedUnit) + throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit)); + + return ToUnit(typedUnit); + }} + + /// + IValueQuantity<{_quantity.ValueType}> IValueQuantity<{_quantity.ValueType}>.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion "); } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs index 72da33a951..ed1025d438 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -103,14 +103,14 @@ public ElectricCharge(double value, ElectricChargeUnit unit) public double Kilocoulombs => As(ElectricChargeUnit.Kilocoulomb); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Megacoulombs => As(ElectricChargeUnit.Megacoulomb); + public double MegaampereHours => As(ElectricChargeUnit.MegaampereHour); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MegaampereHours => As(ElectricChargeUnit.MegaampereHour); + public double Megacoulombs => As(ElectricChargeUnit.Megacoulomb); /// /// Gets a value of this quantity converted into @@ -166,16 +166,16 @@ public ElectricCharge(double value, ElectricChargeUnit unit) public static ElectricCharge FromKilocoulombs(double kilocoulombs) => new ElectricCharge(kilocoulombs, ElectricChargeUnit.Kilocoulomb); /// - /// Creates a from . + /// Creates a from . /// /// If value is NaN or Infinity. - public static ElectricCharge FromMegacoulombs(double megacoulombs) => new ElectricCharge(megacoulombs, ElectricChargeUnit.Megacoulomb); + public static ElectricCharge FromMegaampereHours(double megaamperehours) => new ElectricCharge(megaamperehours, ElectricChargeUnit.MegaampereHour); /// - /// Creates a from . + /// Creates a from . /// /// If value is NaN or Infinity. - public static ElectricCharge FromMegaampereHours(double megaamperehours) => new ElectricCharge(megaamperehours, ElectricChargeUnit.MegaampereHour); + public static ElectricCharge FromMegacoulombs(double megacoulombs) => new ElectricCharge(megacoulombs, ElectricChargeUnit.Megacoulomb); /// /// Creates a from . @@ -251,8 +251,8 @@ private double GetValueInBaseUnit() ElectricChargeUnit.Coulomb => _value, ElectricChargeUnit.KiloampereHour => (_value / 2.77777777777e-4) * 1e3d, ElectricChargeUnit.Kilocoulomb => (_value) * 1e3d, - ElectricChargeUnit.Megacoulomb => (_value) * 1e6d, ElectricChargeUnit.MegaampereHour => (_value / 2.77777777777e-4) * 1e6d, + ElectricChargeUnit.Megacoulomb => (_value) * 1e6d, ElectricChargeUnit.Microcoulomb => (_value) * 1e-6d, ElectricChargeUnit.MilliampereHour => (_value / 2.77777777777e-4) * 1e-3d, ElectricChargeUnit.Millicoulomb => (_value) * 1e-3d, @@ -275,8 +275,8 @@ private double GetValueAs(ElectricChargeUnit unit) ElectricChargeUnit.Coulomb => baseUnitValue, ElectricChargeUnit.KiloampereHour => (baseUnitValue * 2.77777777777e-4) / 1e3d, ElectricChargeUnit.Kilocoulomb => (baseUnitValue) / 1e3d, - ElectricChargeUnit.Megacoulomb => (baseUnitValue) / 1e6d, ElectricChargeUnit.MegaampereHour => (baseUnitValue * 2.77777777777e-4) / 1e6d, + ElectricChargeUnit.Megacoulomb => (baseUnitValue) / 1e6d, ElectricChargeUnit.Microcoulomb => (baseUnitValue) / 1e-6d, ElectricChargeUnit.MilliampereHour => (baseUnitValue * 2.77777777777e-4) / 1e-3d, ElectricChargeUnit.Millicoulomb => (baseUnitValue) / 1e-3d, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricChargeUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricChargeUnit.g.cs index c648f7fc82..bf853e9a10 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricChargeUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricChargeUnit.g.cs @@ -29,8 +29,8 @@ public enum ElectricChargeUnit Coulomb = 2, KiloampereHour = 3, Kilocoulomb = 13, - Megacoulomb = 6, MegaampereHour = 4, + Megacoulomb = 6, Microcoulomb = 11, MilliampereHour = 5, Millicoulomb = 7, diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricChargeExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricChargeExtensionsTest.g.cs index f2e71dad54..145ccf7a39 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricChargeExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricChargeExtensionsTest.g.cs @@ -40,14 +40,14 @@ public void NumberToKiloampereHoursTest() => public void NumberToKilocoulombsTest() => Assert.Equal(ElectricCharge.FromKilocoulombs(2), 2.Kilocoulombs()); - [Fact] - public void NumberToMegacoulombsTest() => - Assert.Equal(ElectricCharge.FromMegacoulombs(2), 2.Megacoulombs()); - [Fact] public void NumberToMegaampereHoursTest() => Assert.Equal(ElectricCharge.FromMegaampereHours(2), 2.MegaampereHours()); + [Fact] + public void NumberToMegacoulombsTest() => + Assert.Equal(ElectricCharge.FromMegacoulombs(2), 2.Megacoulombs()); + [Fact] public void NumberToMicrocoulombsTest() => Assert.Equal(ElectricCharge.FromMicrocoulombs(2), 2.Microcoulombs()); diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeExtensions.g.cs index 04a5ff16df..8ec54dc11b 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeExtensions.g.cs @@ -44,14 +44,14 @@ public static ElectricCharge KiloampereHours(this T value) => public static ElectricCharge Kilocoulombs(this T value) => ElectricCharge.FromKilocoulombs(Convert.ToDouble(value)); - /// - public static ElectricCharge Megacoulombs(this T value) => - ElectricCharge.FromMegacoulombs(Convert.ToDouble(value)); - /// public static ElectricCharge MegaampereHours(this T value) => ElectricCharge.FromMegaampereHours(Convert.ToDouble(value)); + /// + public static ElectricCharge Megacoulombs(this T value) => + ElectricCharge.FromMegacoulombs(Convert.ToDouble(value)); + /// public static ElectricCharge Microcoulombs(this T value) => ElectricCharge.FromMicrocoulombs(Convert.ToDouble(value)); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index c4742b14ee..0307409152 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -42,8 +42,8 @@ public abstract partial class ElectricChargeTestsBase : QuantityTestsBase protected abstract double CoulombsInOneCoulomb { get; } protected abstract double KiloampereHoursInOneCoulomb { get; } protected abstract double KilocoulombsInOneCoulomb { get; } - protected abstract double MegacoulombsInOneCoulomb { get; } protected abstract double MegaampereHoursInOneCoulomb { get; } + protected abstract double MegacoulombsInOneCoulomb { get; } protected abstract double MicrocoulombsInOneCoulomb { get; } protected abstract double MilliampereHoursInOneCoulomb { get; } protected abstract double MillicoulombsInOneCoulomb { get; } @@ -55,8 +55,8 @@ public abstract partial class ElectricChargeTestsBase : QuantityTestsBase protected virtual double CoulombsTolerance { get { return 1e-5; } } protected virtual double KiloampereHoursTolerance { get { return 1e-5; } } protected virtual double KilocoulombsTolerance { get { return 1e-5; } } - protected virtual double MegacoulombsTolerance { get { return 1e-5; } } protected virtual double MegaampereHoursTolerance { get { return 1e-5; } } + protected virtual double MegacoulombsTolerance { get { return 1e-5; } } protected virtual double MicrocoulombsTolerance { get { return 1e-5; } } protected virtual double MilliampereHoursTolerance { get { return 1e-5; } } protected virtual double MillicoulombsTolerance { get { return 1e-5; } } @@ -72,8 +72,8 @@ public abstract partial class ElectricChargeTestsBase : QuantityTestsBase ElectricChargeUnit.Coulomb => (CoulombsInOneCoulomb, CoulombsTolerance), ElectricChargeUnit.KiloampereHour => (KiloampereHoursInOneCoulomb, KiloampereHoursTolerance), ElectricChargeUnit.Kilocoulomb => (KilocoulombsInOneCoulomb, KilocoulombsTolerance), - ElectricChargeUnit.Megacoulomb => (MegacoulombsInOneCoulomb, MegacoulombsTolerance), ElectricChargeUnit.MegaampereHour => (MegaampereHoursInOneCoulomb, MegaampereHoursTolerance), + ElectricChargeUnit.Megacoulomb => (MegacoulombsInOneCoulomb, MegacoulombsTolerance), ElectricChargeUnit.Microcoulomb => (MicrocoulombsInOneCoulomb, MicrocoulombsTolerance), ElectricChargeUnit.MilliampereHour => (MilliampereHoursInOneCoulomb, MilliampereHoursTolerance), ElectricChargeUnit.Millicoulomb => (MillicoulombsInOneCoulomb, MillicoulombsTolerance), @@ -89,8 +89,8 @@ public abstract partial class ElectricChargeTestsBase : QuantityTestsBase new object[] { ElectricChargeUnit.Coulomb }, new object[] { ElectricChargeUnit.KiloampereHour }, new object[] { ElectricChargeUnit.Kilocoulomb }, - new object[] { ElectricChargeUnit.Megacoulomb }, new object[] { ElectricChargeUnit.MegaampereHour }, + new object[] { ElectricChargeUnit.Megacoulomb }, new object[] { ElectricChargeUnit.Microcoulomb }, new object[] { ElectricChargeUnit.MilliampereHour }, new object[] { ElectricChargeUnit.Millicoulomb }, @@ -162,8 +162,8 @@ public void CoulombToElectricChargeUnits() AssertEx.EqualTolerance(CoulombsInOneCoulomb, coulomb.Coulombs, CoulombsTolerance); AssertEx.EqualTolerance(KiloampereHoursInOneCoulomb, coulomb.KiloampereHours, KiloampereHoursTolerance); AssertEx.EqualTolerance(KilocoulombsInOneCoulomb, coulomb.Kilocoulombs, KilocoulombsTolerance); - AssertEx.EqualTolerance(MegacoulombsInOneCoulomb, coulomb.Megacoulombs, MegacoulombsTolerance); AssertEx.EqualTolerance(MegaampereHoursInOneCoulomb, coulomb.MegaampereHours, MegaampereHoursTolerance); + AssertEx.EqualTolerance(MegacoulombsInOneCoulomb, coulomb.Megacoulombs, MegacoulombsTolerance); AssertEx.EqualTolerance(MicrocoulombsInOneCoulomb, coulomb.Microcoulombs, MicrocoulombsTolerance); AssertEx.EqualTolerance(MilliampereHoursInOneCoulomb, coulomb.MilliampereHours, MilliampereHoursTolerance); AssertEx.EqualTolerance(MillicoulombsInOneCoulomb, coulomb.Millicoulombs, MillicoulombsTolerance); @@ -190,13 +190,13 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() AssertEx.EqualTolerance(1, quantity03.Kilocoulombs, KilocoulombsTolerance); Assert.Equal(ElectricChargeUnit.Kilocoulomb, quantity03.Unit); - var quantity04 = ElectricCharge.From(1, ElectricChargeUnit.Megacoulomb); - AssertEx.EqualTolerance(1, quantity04.Megacoulombs, MegacoulombsTolerance); - Assert.Equal(ElectricChargeUnit.Megacoulomb, quantity04.Unit); + var quantity04 = ElectricCharge.From(1, ElectricChargeUnit.MegaampereHour); + AssertEx.EqualTolerance(1, quantity04.MegaampereHours, MegaampereHoursTolerance); + Assert.Equal(ElectricChargeUnit.MegaampereHour, quantity04.Unit); - var quantity05 = ElectricCharge.From(1, ElectricChargeUnit.MegaampereHour); - AssertEx.EqualTolerance(1, quantity05.MegaampereHours, MegaampereHoursTolerance); - Assert.Equal(ElectricChargeUnit.MegaampereHour, quantity05.Unit); + var quantity05 = ElectricCharge.From(1, ElectricChargeUnit.Megacoulomb); + AssertEx.EqualTolerance(1, quantity05.Megacoulombs, MegacoulombsTolerance); + Assert.Equal(ElectricChargeUnit.Megacoulomb, quantity05.Unit); var quantity06 = ElectricCharge.From(1, ElectricChargeUnit.Microcoulomb); AssertEx.EqualTolerance(1, quantity06.Microcoulombs, MicrocoulombsTolerance); @@ -241,8 +241,8 @@ public void As() AssertEx.EqualTolerance(CoulombsInOneCoulomb, coulomb.As(ElectricChargeUnit.Coulomb), CoulombsTolerance); AssertEx.EqualTolerance(KiloampereHoursInOneCoulomb, coulomb.As(ElectricChargeUnit.KiloampereHour), KiloampereHoursTolerance); AssertEx.EqualTolerance(KilocoulombsInOneCoulomb, coulomb.As(ElectricChargeUnit.Kilocoulomb), KilocoulombsTolerance); - AssertEx.EqualTolerance(MegacoulombsInOneCoulomb, coulomb.As(ElectricChargeUnit.Megacoulomb), MegacoulombsTolerance); AssertEx.EqualTolerance(MegaampereHoursInOneCoulomb, coulomb.As(ElectricChargeUnit.MegaampereHour), MegaampereHoursTolerance); + AssertEx.EqualTolerance(MegacoulombsInOneCoulomb, coulomb.As(ElectricChargeUnit.Megacoulomb), MegacoulombsTolerance); AssertEx.EqualTolerance(MicrocoulombsInOneCoulomb, coulomb.As(ElectricChargeUnit.Microcoulomb), MicrocoulombsTolerance); AssertEx.EqualTolerance(MilliampereHoursInOneCoulomb, coulomb.As(ElectricChargeUnit.MilliampereHour), MilliampereHoursTolerance); AssertEx.EqualTolerance(MillicoulombsInOneCoulomb, coulomb.As(ElectricChargeUnit.Millicoulomb), MillicoulombsTolerance); @@ -312,13 +312,6 @@ public void Parse() Assert.Equal(ElectricChargeUnit.Kilocoulomb, parsed.Unit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - try - { - var parsed = ElectricCharge.Parse("1 MC", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.Megacoulombs, MegacoulombsTolerance); - Assert.Equal(ElectricChargeUnit.Megacoulomb, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - try { var parsed = ElectricCharge.Parse("1 MA-h", CultureInfo.GetCultureInfo("en-US")); @@ -333,6 +326,13 @@ public void Parse() Assert.Equal(ElectricChargeUnit.MegaampereHour, parsed.Unit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsed = ElectricCharge.Parse("1 MC", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.Megacoulombs, MegacoulombsTolerance); + Assert.Equal(ElectricChargeUnit.Megacoulomb, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsed = ElectricCharge.Parse("1 µC", CultureInfo.GetCultureInfo("en-US")); @@ -477,20 +477,20 @@ public void ParseUnit() try { - var parsedUnit = ElectricCharge.ParseUnit("MC", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(ElectricChargeUnit.Megacoulomb, parsedUnit); + var parsedUnit = ElectricCharge.ParseUnit("MA-h", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricChargeUnit.MegaampereHour, parsedUnit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } try { - var parsedUnit = ElectricCharge.ParseUnit("MA-h", CultureInfo.GetCultureInfo("en-US")); + var parsedUnit = ElectricCharge.ParseUnit("MAh", CultureInfo.GetCultureInfo("en-US")); Assert.Equal(ElectricChargeUnit.MegaampereHour, parsedUnit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } try { - var parsedUnit = ElectricCharge.ParseUnit("MAh", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(ElectricChargeUnit.MegaampereHour, parsedUnit); + var parsedUnit = ElectricCharge.ParseUnit("MC", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricChargeUnit.Megacoulomb, parsedUnit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } try @@ -631,8 +631,8 @@ public void ConversionRoundTrip() AssertEx.EqualTolerance(1, ElectricCharge.FromCoulombs(coulomb.Coulombs).Coulombs, CoulombsTolerance); AssertEx.EqualTolerance(1, ElectricCharge.FromKiloampereHours(coulomb.KiloampereHours).Coulombs, KiloampereHoursTolerance); AssertEx.EqualTolerance(1, ElectricCharge.FromKilocoulombs(coulomb.Kilocoulombs).Coulombs, KilocoulombsTolerance); - AssertEx.EqualTolerance(1, ElectricCharge.FromMegacoulombs(coulomb.Megacoulombs).Coulombs, MegacoulombsTolerance); AssertEx.EqualTolerance(1, ElectricCharge.FromMegaampereHours(coulomb.MegaampereHours).Coulombs, MegaampereHoursTolerance); + AssertEx.EqualTolerance(1, ElectricCharge.FromMegacoulombs(coulomb.Megacoulombs).Coulombs, MegacoulombsTolerance); AssertEx.EqualTolerance(1, ElectricCharge.FromMicrocoulombs(coulomb.Microcoulombs).Coulombs, MicrocoulombsTolerance); AssertEx.EqualTolerance(1, ElectricCharge.FromMilliampereHours(coulomb.MilliampereHours).Coulombs, MilliampereHoursTolerance); AssertEx.EqualTolerance(1, ElectricCharge.FromMillicoulombs(coulomb.Millicoulombs).Coulombs, MillicoulombsTolerance); @@ -789,8 +789,8 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() Assert.Equal("1 C", new ElectricCharge(1, ElectricChargeUnit.Coulomb).ToString()); Assert.Equal("1 kA-h", new ElectricCharge(1, ElectricChargeUnit.KiloampereHour).ToString()); Assert.Equal("1 kC", new ElectricCharge(1, ElectricChargeUnit.Kilocoulomb).ToString()); - Assert.Equal("1 MC", new ElectricCharge(1, ElectricChargeUnit.Megacoulomb).ToString()); Assert.Equal("1 MA-h", new ElectricCharge(1, ElectricChargeUnit.MegaampereHour).ToString()); + Assert.Equal("1 MC", new ElectricCharge(1, ElectricChargeUnit.Megacoulomb).ToString()); Assert.Equal("1 µC", new ElectricCharge(1, ElectricChargeUnit.Microcoulomb).ToString()); Assert.Equal("1 mA-h", new ElectricCharge(1, ElectricChargeUnit.MilliampereHour).ToString()); Assert.Equal("1 mC", new ElectricCharge(1, ElectricChargeUnit.Millicoulomb).ToString()); @@ -813,8 +813,8 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture Assert.Equal("1 C", new ElectricCharge(1, ElectricChargeUnit.Coulomb).ToString(swedishCulture)); Assert.Equal("1 kA-h", new ElectricCharge(1, ElectricChargeUnit.KiloampereHour).ToString(swedishCulture)); Assert.Equal("1 kC", new ElectricCharge(1, ElectricChargeUnit.Kilocoulomb).ToString(swedishCulture)); - Assert.Equal("1 MC", new ElectricCharge(1, ElectricChargeUnit.Megacoulomb).ToString(swedishCulture)); Assert.Equal("1 MA-h", new ElectricCharge(1, ElectricChargeUnit.MegaampereHour).ToString(swedishCulture)); + Assert.Equal("1 MC", new ElectricCharge(1, ElectricChargeUnit.Megacoulomb).ToString(swedishCulture)); Assert.Equal("1 µC", new ElectricCharge(1, ElectricChargeUnit.Microcoulomb).ToString(swedishCulture)); Assert.Equal("1 mA-h", new ElectricCharge(1, ElectricChargeUnit.MilliampereHour).ToString(swedishCulture)); Assert.Equal("1 mC", new ElectricCharge(1, ElectricChargeUnit.Millicoulomb).ToString(swedishCulture)); diff --git a/UnitsNet.Tests/IValueQuantityTests.cs b/UnitsNet.Tests/IValueQuantityTests.cs index 618ad22194..bea6e392bb 100644 --- a/UnitsNet.Tests/IValueQuantityTests.cs +++ b/UnitsNet.Tests/IValueQuantityTests.cs @@ -50,5 +50,33 @@ public void IValueQuantityTDecimal_AsUnitSystem_ReturnsDecimal() IValueQuantity decimalQuantity = Power.FromMegawatts(1234.5); Assert.IsType(decimalQuantity.As(UnitSystem.SI)); } + + [Fact] + public void IValueQuantityTDouble_ToUnitEnum_ReturnsIValueQuantityTDouble() + { + IValueQuantity doubleQuantity = Temperature.FromDegreesCelsius(1234.5); + Assert.IsAssignableFrom>(doubleQuantity.ToUnit(TemperatureUnit.Kelvin)); + } + + [Fact] + public void IValueQuantityTDouble_ToUnitUnitSystem_ReturnsIValueQuantityTDouble() + { + IValueQuantity doubleQuantity = Temperature.FromDegreesCelsius(1234.5); + Assert.IsAssignableFrom>(doubleQuantity.ToUnit(UnitSystem.SI)); + } + + [Fact] + public void IValueQuantityTDecimal_ToUnitEnum_ReturnsIValueQuantityTDecimal() + { + IValueQuantity decimalQuantity = Power.FromWatts(1234.5); + Assert.IsAssignableFrom>(decimalQuantity.ToUnit(PowerUnit.ElectricalHorsepower)); + } + + [Fact] + public void IValueQuantityTDecimal_ToUnitUnitSystem_ReturnsIValueQuantityTDecimal() + { + IValueQuantity decimalQuantity = Power.FromWatts(1234.5); + Assert.IsAssignableFrom>(decimalQuantity.ToUnit(UnitSystem.SI)); + } } } diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index e2e2b73014..50c61da5df 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -1043,6 +1043,18 @@ public Acceleration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not AccelerationUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AccelerationUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 25ae573ca2..d0e2a9b1ca 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -1050,6 +1050,18 @@ public AmountOfSubstance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not AmountOfSubstanceUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmountOfSubstanceUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index bd8329968c..26a4b35dd2 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -827,6 +827,18 @@ public AmplitudeRatio ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not AmplitudeRatioUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmplitudeRatioUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index cb2b23e64a..27c248be69 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -1083,6 +1083,18 @@ public Angle ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not AngleUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AngleUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index 390686e4be..baf290ad86 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -798,6 +798,18 @@ public ApparentEnergy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ApparentEnergyUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentEnergyUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index 72538ab1c4..bfc6980144 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -861,6 +861,18 @@ public ApparentPower ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ApparentPowerUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentPowerUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index d2fe2adced..4de92cb165 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -1056,6 +1056,18 @@ public Area ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not AreaUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index b923ef3d78..f989873016 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -798,6 +798,18 @@ public AreaDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not AreaDensityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaDensityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 0806082620..2a63adeb01 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -861,6 +861,18 @@ public AreaMomentOfInertia ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not AreaMomentOfInertiaUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaMomentOfInertiaUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index 86ab0212a8..49e9903f31 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -1296,6 +1296,18 @@ public BitRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not BitRateUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BitRateUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index dcbcb1a0e3..3cb5f0382c 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -798,6 +798,18 @@ public BrakeSpecificFuelConsumption ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not BrakeSpecificFuelConsumptionUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BrakeSpecificFuelConsumptionUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index 7031bb28e6..26743b160c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -885,6 +885,18 @@ public Capacitance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not CapacitanceUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CapacitanceUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 11765beaa8..6b116c03db 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -798,6 +798,18 @@ public CoefficientOfThermalExpansion ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not CoefficientOfThermalExpansionUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CoefficientOfThermalExpansionUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs index d85d3e308e..d9745f5396 100644 --- a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs @@ -882,6 +882,18 @@ public Compressibility ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not CompressibilityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CompressibilityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index f4344b0897..ae27d2e4d7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -1813,6 +1813,18 @@ public Density ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not DensityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DensityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index 81952b7297..ceea4f803a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -976,6 +976,18 @@ public Duration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not DurationUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DurationUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index 33f9a57a4c..eb1ad0a3ae 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -948,6 +948,18 @@ public DynamicViscosity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not DynamicViscosityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DynamicViscosityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 0a999b6a05..e71b52a4ee 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -819,6 +819,18 @@ public ElectricAdmittance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ElectricAdmittanceUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricAdmittanceUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index 07a54de5b0..3c0b3b2ec7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -72,8 +72,8 @@ static ElectricCharge() new UnitInfo(ElectricChargeUnit.Coulomb, "Coulombs", BaseUnits.Undefined), new UnitInfo(ElectricChargeUnit.KiloampereHour, "KiloampereHours", BaseUnits.Undefined), new UnitInfo(ElectricChargeUnit.Kilocoulomb, "Kilocoulombs", BaseUnits.Undefined), - new UnitInfo(ElectricChargeUnit.Megacoulomb, "Megacoulombs", BaseUnits.Undefined), new UnitInfo(ElectricChargeUnit.MegaampereHour, "MegaampereHours", BaseUnits.Undefined), + new UnitInfo(ElectricChargeUnit.Megacoulomb, "Megacoulombs", BaseUnits.Undefined), new UnitInfo(ElectricChargeUnit.Microcoulomb, "Microcoulombs", BaseUnits.Undefined), new UnitInfo(ElectricChargeUnit.MilliampereHour, "MilliampereHours", BaseUnits.Undefined), new UnitInfo(ElectricChargeUnit.Millicoulomb, "Millicoulombs", BaseUnits.Undefined), @@ -203,14 +203,14 @@ public ElectricCharge(double value, UnitSystem unitSystem) public double Kilocoulombs => As(ElectricChargeUnit.Kilocoulomb); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Megacoulombs => As(ElectricChargeUnit.Megacoulomb); + public double MegaampereHours => As(ElectricChargeUnit.MegaampereHour); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MegaampereHours => As(ElectricChargeUnit.MegaampereHour); + public double Megacoulombs => As(ElectricChargeUnit.Megacoulomb); /// /// Gets a value of this quantity converted into @@ -251,8 +251,8 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ElectricChargeUnit.AmpereHour, ElectricChargeUnit.Coulomb, quantity => quantity.ToUnit(ElectricChargeUnit.Coulomb)); unitConverter.SetConversionFunction(ElectricChargeUnit.KiloampereHour, ElectricChargeUnit.Coulomb, quantity => quantity.ToUnit(ElectricChargeUnit.Coulomb)); unitConverter.SetConversionFunction(ElectricChargeUnit.Kilocoulomb, ElectricChargeUnit.Coulomb, quantity => quantity.ToUnit(ElectricChargeUnit.Coulomb)); - unitConverter.SetConversionFunction(ElectricChargeUnit.Megacoulomb, ElectricChargeUnit.Coulomb, quantity => quantity.ToUnit(ElectricChargeUnit.Coulomb)); unitConverter.SetConversionFunction(ElectricChargeUnit.MegaampereHour, ElectricChargeUnit.Coulomb, quantity => quantity.ToUnit(ElectricChargeUnit.Coulomb)); + unitConverter.SetConversionFunction(ElectricChargeUnit.Megacoulomb, ElectricChargeUnit.Coulomb, quantity => quantity.ToUnit(ElectricChargeUnit.Coulomb)); unitConverter.SetConversionFunction(ElectricChargeUnit.Microcoulomb, ElectricChargeUnit.Coulomb, quantity => quantity.ToUnit(ElectricChargeUnit.Coulomb)); unitConverter.SetConversionFunction(ElectricChargeUnit.MilliampereHour, ElectricChargeUnit.Coulomb, quantity => quantity.ToUnit(ElectricChargeUnit.Coulomb)); unitConverter.SetConversionFunction(ElectricChargeUnit.Millicoulomb, ElectricChargeUnit.Coulomb, quantity => quantity.ToUnit(ElectricChargeUnit.Coulomb)); @@ -266,8 +266,8 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ElectricChargeUnit.Coulomb, ElectricChargeUnit.AmpereHour, quantity => quantity.ToUnit(ElectricChargeUnit.AmpereHour)); unitConverter.SetConversionFunction(ElectricChargeUnit.Coulomb, ElectricChargeUnit.KiloampereHour, quantity => quantity.ToUnit(ElectricChargeUnit.KiloampereHour)); unitConverter.SetConversionFunction(ElectricChargeUnit.Coulomb, ElectricChargeUnit.Kilocoulomb, quantity => quantity.ToUnit(ElectricChargeUnit.Kilocoulomb)); - unitConverter.SetConversionFunction(ElectricChargeUnit.Coulomb, ElectricChargeUnit.Megacoulomb, quantity => quantity.ToUnit(ElectricChargeUnit.Megacoulomb)); unitConverter.SetConversionFunction(ElectricChargeUnit.Coulomb, ElectricChargeUnit.MegaampereHour, quantity => quantity.ToUnit(ElectricChargeUnit.MegaampereHour)); + unitConverter.SetConversionFunction(ElectricChargeUnit.Coulomb, ElectricChargeUnit.Megacoulomb, quantity => quantity.ToUnit(ElectricChargeUnit.Megacoulomb)); unitConverter.SetConversionFunction(ElectricChargeUnit.Coulomb, ElectricChargeUnit.Microcoulomb, quantity => quantity.ToUnit(ElectricChargeUnit.Microcoulomb)); unitConverter.SetConversionFunction(ElectricChargeUnit.Coulomb, ElectricChargeUnit.MilliampereHour, quantity => quantity.ToUnit(ElectricChargeUnit.MilliampereHour)); unitConverter.SetConversionFunction(ElectricChargeUnit.Coulomb, ElectricChargeUnit.Millicoulomb, quantity => quantity.ToUnit(ElectricChargeUnit.Millicoulomb)); @@ -281,8 +281,8 @@ internal static void MapGeneratedLocalizations(UnitAbbreviationsCache unitAbbrev unitAbbreviationsCache.PerformAbbreviationMapping(ElectricChargeUnit.Coulomb, new CultureInfo("en-US"), false, true, new string[]{"C"}); unitAbbreviationsCache.PerformAbbreviationMapping(ElectricChargeUnit.KiloampereHour, new CultureInfo("en-US"), false, true, new string[]{"kA-h", "kAh"}); unitAbbreviationsCache.PerformAbbreviationMapping(ElectricChargeUnit.Kilocoulomb, new CultureInfo("en-US"), false, true, new string[]{"kC"}); - unitAbbreviationsCache.PerformAbbreviationMapping(ElectricChargeUnit.Megacoulomb, new CultureInfo("en-US"), false, true, new string[]{"MC"}); unitAbbreviationsCache.PerformAbbreviationMapping(ElectricChargeUnit.MegaampereHour, new CultureInfo("en-US"), false, true, new string[]{"MA-h", "MAh"}); + unitAbbreviationsCache.PerformAbbreviationMapping(ElectricChargeUnit.Megacoulomb, new CultureInfo("en-US"), false, true, new string[]{"MC"}); unitAbbreviationsCache.PerformAbbreviationMapping(ElectricChargeUnit.Microcoulomb, new CultureInfo("en-US"), false, true, new string[]{"µC"}); unitAbbreviationsCache.PerformAbbreviationMapping(ElectricChargeUnit.MilliampereHour, new CultureInfo("en-US"), false, true, new string[]{"mA-h", "mAh"}); unitAbbreviationsCache.PerformAbbreviationMapping(ElectricChargeUnit.Millicoulomb, new CultureInfo("en-US"), false, true, new string[]{"mC"}); @@ -356,23 +356,23 @@ public static ElectricCharge FromKilocoulombs(QuantityValue kilocoulombs) } /// - /// Creates a from . + /// Creates a from . /// /// If value is NaN or Infinity. - public static ElectricCharge FromMegacoulombs(QuantityValue megacoulombs) + public static ElectricCharge FromMegaampereHours(QuantityValue megaamperehours) { - double value = (double) megacoulombs; - return new ElectricCharge(value, ElectricChargeUnit.Megacoulomb); + double value = (double) megaamperehours; + return new ElectricCharge(value, ElectricChargeUnit.MegaampereHour); } /// - /// Creates a from . + /// Creates a from . /// /// If value is NaN or Infinity. - public static ElectricCharge FromMegaampereHours(QuantityValue megaamperehours) + public static ElectricCharge FromMegacoulombs(QuantityValue megacoulombs) { - double value = (double) megaamperehours; - return new ElectricCharge(value, ElectricChargeUnit.MegaampereHour); + double value = (double) megacoulombs; + return new ElectricCharge(value, ElectricChargeUnit.Megacoulomb); } /// @@ -903,8 +903,8 @@ private bool TryToUnit(ElectricChargeUnit unit, [NotNullWhen(true)] out Electric (ElectricChargeUnit.AmpereHour, ElectricChargeUnit.Coulomb) => new ElectricCharge(_value / 2.77777777777e-4, ElectricChargeUnit.Coulomb), (ElectricChargeUnit.KiloampereHour, ElectricChargeUnit.Coulomb) => new ElectricCharge((_value / 2.77777777777e-4) * 1e3d, ElectricChargeUnit.Coulomb), (ElectricChargeUnit.Kilocoulomb, ElectricChargeUnit.Coulomb) => new ElectricCharge((_value) * 1e3d, ElectricChargeUnit.Coulomb), - (ElectricChargeUnit.Megacoulomb, ElectricChargeUnit.Coulomb) => new ElectricCharge((_value) * 1e6d, ElectricChargeUnit.Coulomb), (ElectricChargeUnit.MegaampereHour, ElectricChargeUnit.Coulomb) => new ElectricCharge((_value / 2.77777777777e-4) * 1e6d, ElectricChargeUnit.Coulomb), + (ElectricChargeUnit.Megacoulomb, ElectricChargeUnit.Coulomb) => new ElectricCharge((_value) * 1e6d, ElectricChargeUnit.Coulomb), (ElectricChargeUnit.Microcoulomb, ElectricChargeUnit.Coulomb) => new ElectricCharge((_value) * 1e-6d, ElectricChargeUnit.Coulomb), (ElectricChargeUnit.MilliampereHour, ElectricChargeUnit.Coulomb) => new ElectricCharge((_value / 2.77777777777e-4) * 1e-3d, ElectricChargeUnit.Coulomb), (ElectricChargeUnit.Millicoulomb, ElectricChargeUnit.Coulomb) => new ElectricCharge((_value) * 1e-3d, ElectricChargeUnit.Coulomb), @@ -915,8 +915,8 @@ private bool TryToUnit(ElectricChargeUnit unit, [NotNullWhen(true)] out Electric (ElectricChargeUnit.Coulomb, ElectricChargeUnit.AmpereHour) => new ElectricCharge(_value * 2.77777777777e-4, ElectricChargeUnit.AmpereHour), (ElectricChargeUnit.Coulomb, ElectricChargeUnit.KiloampereHour) => new ElectricCharge((_value * 2.77777777777e-4) / 1e3d, ElectricChargeUnit.KiloampereHour), (ElectricChargeUnit.Coulomb, ElectricChargeUnit.Kilocoulomb) => new ElectricCharge((_value) / 1e3d, ElectricChargeUnit.Kilocoulomb), - (ElectricChargeUnit.Coulomb, ElectricChargeUnit.Megacoulomb) => new ElectricCharge((_value) / 1e6d, ElectricChargeUnit.Megacoulomb), (ElectricChargeUnit.Coulomb, ElectricChargeUnit.MegaampereHour) => new ElectricCharge((_value * 2.77777777777e-4) / 1e6d, ElectricChargeUnit.MegaampereHour), + (ElectricChargeUnit.Coulomb, ElectricChargeUnit.Megacoulomb) => new ElectricCharge((_value) / 1e6d, ElectricChargeUnit.Megacoulomb), (ElectricChargeUnit.Coulomb, ElectricChargeUnit.Microcoulomb) => new ElectricCharge((_value) / 1e-6d, ElectricChargeUnit.Microcoulomb), (ElectricChargeUnit.Coulomb, ElectricChargeUnit.MilliampereHour) => new ElectricCharge((_value * 2.77777777777e-4) / 1e-3d, ElectricChargeUnit.MilliampereHour), (ElectricChargeUnit.Coulomb, ElectricChargeUnit.Millicoulomb) => new ElectricCharge((_value) / 1e-3d, ElectricChargeUnit.Millicoulomb), @@ -969,6 +969,18 @@ public ElectricCharge ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ElectricChargeUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 2c061edd35..5d22f8248d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -759,6 +759,18 @@ public ElectricChargeDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ElectricChargeDensityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeDensityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index fbeffa6a10..d5b1e09d3d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -843,6 +843,18 @@ public ElectricConductance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ElectricConductanceUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductanceUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 54b3701cf2..3e9c568fe9 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -864,6 +864,18 @@ public ElectricConductivity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ElectricConductivityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductivityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index ebaf25c224..5833e54875 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -924,6 +924,18 @@ public ElectricCurrent ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ElectricCurrentUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index 9fac4ca5a8..f73aa42c69 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -801,6 +801,18 @@ public ElectricCurrentDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ElectricCurrentDensityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentDensityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index ac84402bc5..ee29ac5b7a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -819,6 +819,18 @@ public ElectricCurrentGradient ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ElectricCurrentGradientUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentGradientUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index a1cf982929..8ab10f5056 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -759,6 +759,18 @@ public ElectricField ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ElectricFieldUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricFieldUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index ad43a0b744..9fe8cc6a8c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -843,6 +843,18 @@ public ElectricInductance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ElectricInductanceUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricInductanceUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index 3202181148..1655b702a9 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -867,6 +867,18 @@ public ElectricPotential ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ElectricPotentialUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index aee99efcf5..8c243b0b9b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -840,6 +840,18 @@ public ElectricPotentialAc ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ElectricPotentialAcUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialAcUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index c6dde2471c..204fdb920b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -1155,6 +1155,18 @@ public ElectricPotentialChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ElectricPotentialChangeRateUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialChangeRateUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index 31d46820e6..7e329382a4 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -840,6 +840,18 @@ public ElectricPotentialDc ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ElectricPotentialDcUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialDcUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index 5e2263fd44..dca339be01 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -882,6 +882,18 @@ public ElectricResistance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ElectricResistanceUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistanceUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index 35f7848d78..0159a5d433 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -1032,6 +1032,18 @@ public ElectricResistivity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ElectricResistivityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistivityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index f92e1fbbeb..6a79037987 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -801,6 +801,18 @@ public ElectricSurfaceChargeDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ElectricSurfaceChargeDensityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricSurfaceChargeDensityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index 14689baae0..c762157cd9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -1554,6 +1554,18 @@ public Energy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not EnergyUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EnergyUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs index 6937e1f687..280a9d6a72 100644 --- a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs @@ -987,6 +987,18 @@ public EnergyDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not EnergyDensityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EnergyDensityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index 024149f0c0..d66843e420 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -882,6 +882,18 @@ public Entropy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not EntropyUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EntropyUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 0d676c6075..88c7b25449 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -1063,6 +1063,18 @@ public Force ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ForceUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index f56e119137..c0bc760270 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -1050,6 +1050,18 @@ public ForceChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ForceChangeRateUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceChangeRateUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index d40a4971e6..c147c0f280 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -1539,6 +1539,18 @@ public ForcePerLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ForcePerLengthUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForcePerLengthUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index 81c6952732..f0d6e735ed 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -1017,6 +1017,18 @@ public Frequency ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not FrequencyUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FrequencyUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index fdbe10c6c2..7b513711f6 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -822,6 +822,18 @@ public FuelEfficiency ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not FuelEfficiencyUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FuelEfficiencyUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index 24e5e821d2..2e1587b1d6 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -1113,6 +1113,18 @@ public HeatFlux ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not HeatFluxUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatFluxUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 449deb7fcd..36ebd8f183 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -863,6 +863,18 @@ public HeatTransferCoefficient ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not HeatTransferCoefficientUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatTransferCoefficientUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index d2e31b2504..9a61690f4d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -822,6 +822,18 @@ public Illuminance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not IlluminanceUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IlluminanceUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs index a1e1a0077c..7f106772e6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs @@ -1008,6 +1008,18 @@ public Impulse ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ImpulseUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ImpulseUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 46f4673b28..9bacae7e96 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -1293,6 +1293,18 @@ public Information ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not InformationUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(InformationUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index b0e0fb1e68..d959da58da 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -1029,6 +1029,18 @@ public Irradiance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not IrradianceUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradianceUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index 40903ca2eb..49c9acc7ad 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -885,6 +885,18 @@ public Irradiation ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not IrradiationUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradiationUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs index 52cec9ebfb..8943c98193 100644 --- a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs @@ -977,6 +977,18 @@ public Jerk ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not JerkUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(JerkUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 81b131471c..c6b6d2d859 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -935,6 +935,18 @@ public KinematicViscosity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not KinematicViscosityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(KinematicViscosityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index ff28962c97..bd0324ed5f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -1546,6 +1546,18 @@ public Length ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not LengthUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LengthUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index c01cbf03ae..f175e4459b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -785,6 +785,18 @@ public Level ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not LevelUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LevelUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index fa0ff79e46..b0e899934d 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -1032,6 +1032,18 @@ public LinearDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not LinearDensityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearDensityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index 6a90199665..671c648817 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -1263,6 +1263,18 @@ public LinearPowerDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not LinearPowerDensityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearPowerDensityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs index 5136eb3c3c..f1adbfe009 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs @@ -948,6 +948,18 @@ public Luminance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not LuminanceUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminanceUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index 13ead55b8a..e8b2c721b0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -1032,6 +1032,18 @@ public Luminosity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not LuminosityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminosityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index 08c8cc09af..6b27265185 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -759,6 +759,18 @@ public LuminousFlux ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not LuminousFluxUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousFluxUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index 93b8808c63..4872fa2242 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -759,6 +759,18 @@ public LuminousIntensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not LuminousIntensityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousIntensityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index 71e02f7850..d8821319dc 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -864,6 +864,18 @@ public MagneticField ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not MagneticFieldUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFieldUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index 0124a7e41b..b4a02e2457 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -759,6 +759,18 @@ public MagneticFlux ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not MagneticFluxUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFluxUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index a8379f3961..519e288d50 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -759,6 +759,18 @@ public Magnetization ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not MagnetizationUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagnetizationUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index 03c15d8131..4d09a9ed3f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -1295,6 +1295,18 @@ public Mass ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not MassUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index d9ac5d25a0..60036b0425 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -1771,6 +1771,18 @@ public MassConcentration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not MassConcentrationUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassConcentrationUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index e47147d06d..408166d50a 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -1430,6 +1430,18 @@ public MassFlow ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not MassFlowUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFlowUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index e33db8cc98..279e541850 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -987,6 +987,18 @@ public MassFlux ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not MassFluxUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFluxUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 301ddbe199..8c824f4dc5 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -1242,6 +1242,18 @@ public MassFraction ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not MassFractionUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFractionUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index f537909ca8..4b67bdebff 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -1323,6 +1323,18 @@ public MassMomentOfInertia ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not MassMomentOfInertiaUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassMomentOfInertiaUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index 9cf60cc31e..6f67309dbd 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -798,6 +798,18 @@ public MolarEnergy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not MolarEnergyUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEnergyUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index ffb0f85618..cd79b26ad1 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -798,6 +798,18 @@ public MolarEntropy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not MolarEntropyUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEntropyUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs index e83b09aa93..9759e8d22d 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs @@ -924,6 +924,18 @@ public MolarFlow ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not MolarFlowUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarFlowUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 48c3f38c83..8de95c9961 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -1020,6 +1020,18 @@ public MolarMass ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not MolarMassUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarMassUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index 5b044c3b7c..6bbcc8ef82 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -969,6 +969,18 @@ public Molarity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not MolarityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index e8b62399a1..f799fbbd69 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -759,6 +759,18 @@ public Permeability ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not PermeabilityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermeabilityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index c30869b77d..a3ed041fde 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -759,6 +759,18 @@ public Permittivity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not PermittivityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermittivityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs index caf5cae77e..ca623e65f5 100644 --- a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs @@ -843,6 +843,18 @@ public PorousMediumPermeability ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not PorousMediumPermeabilityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PorousMediumPermeabilityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index 46983bed3f..bfdbd51162 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -1293,6 +1293,18 @@ public Power ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not PowerUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index 6a855b4c71..98524dd812 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -1659,6 +1659,18 @@ public PowerDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not PowerDensityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerDensityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index a10602aafd..cbbd8c2b8f 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -785,6 +785,18 @@ public PowerRatio ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not PowerRatioUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerRatioUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index e4b39b336a..f9abbb6f9b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -1795,6 +1795,18 @@ public Pressure ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not PressureUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index 90974ef6d2..e1976e3ace 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -1043,6 +1043,18 @@ public PressureChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not PressureChangeRateUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureChangeRateUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index 838593287d..bb44dc2933 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -861,6 +861,18 @@ public Ratio ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not RatioUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index 4e899c61bc..6267989315 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -777,6 +777,18 @@ public RatioChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not RatioChangeRateUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioChangeRateUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index 37fda2ae32..7f6dfffdc7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -798,6 +798,18 @@ public ReactiveEnergy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ReactiveEnergyUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactiveEnergyUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index 0b088e432b..5a1776d5e2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -819,6 +819,18 @@ public ReactivePower ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ReactivePowerUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactivePowerUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index cd5405951d..c5ffc1a5c4 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -969,6 +969,18 @@ public ReciprocalArea ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ReciprocalAreaUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalAreaUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index b9342e2fab..986439bcda 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -948,6 +948,18 @@ public ReciprocalLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ReciprocalLengthUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalLengthUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index 0b5498bb1e..cd5e296d3c 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -756,6 +756,18 @@ public RelativeHumidity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not RelativeHumidityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RelativeHumidityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 26781ee05e..f11b7e848f 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -819,6 +819,18 @@ public RotationalAcceleration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not RotationalAccelerationUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalAccelerationUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index d566974f62..9d1abc24bb 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -1020,6 +1020,18 @@ public RotationalSpeed ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not RotationalSpeedUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalSpeedUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index 95b1b774be..3b5c25472e 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -1428,6 +1428,18 @@ public RotationalStiffness ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not RotationalStiffnessUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 52cad25636..45eab6c224 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -840,6 +840,18 @@ public RotationalStiffnessPerLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not RotationalStiffnessPerLengthUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessPerLengthUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index 7eaa0d9bbd..869da4bfc8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -756,6 +756,18 @@ public Scalar ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ScalarUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ScalarUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index d1bc1c2dda..a47828309c 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -759,6 +759,18 @@ public SolidAngle ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not SolidAngleUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SolidAngleUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index 411d7ec4c2..5bc5bb4b01 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -1368,6 +1368,18 @@ public SpecificEnergy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not SpecificEnergyUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEnergyUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index 226a77f0da..2b5330fc24 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -924,6 +924,18 @@ public SpecificEntropy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not SpecificEntropyUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEntropyUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 1ccb7e8053..5ad44da6c1 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -822,6 +822,18 @@ public SpecificFuelConsumption ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not SpecificFuelConsumptionUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificFuelConsumptionUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index 19fbe856df..8bf013ba2d 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -798,6 +798,18 @@ public SpecificVolume ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not SpecificVolumeUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificVolumeUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index f82ead3104..07c10183ef 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -1095,6 +1095,18 @@ public SpecificWeight ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not SpecificWeightUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificWeightUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index 74d6dcbf59..1fccc6e4b3 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -1452,6 +1452,18 @@ public Speed ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not SpeedUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpeedUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 83e7cf5737..f89661aea9 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -924,6 +924,18 @@ public StandardVolumeFlow ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not StandardVolumeFlowUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(StandardVolumeFlowUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index d9655e3875..eca5bdb8b4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -896,6 +896,18 @@ public Temperature ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not TemperatureUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 2202086d4a..0e449a91cc 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -945,6 +945,18 @@ public TemperatureChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not TemperatureChangeRateUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureChangeRateUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 55486d0487..3e2be136aa 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -924,6 +924,18 @@ public TemperatureDelta ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not TemperatureDeltaUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureDeltaUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs index 799fa2b9ed..972b7a4cf8 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -819,6 +819,18 @@ public TemperatureGradient ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not TemperatureGradientUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureGradientUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index 649bacbab6..38984e4055 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -780,6 +780,18 @@ public ThermalConductivity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ThermalConductivityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalConductivityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index 7807635346..8f1d252108 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -861,6 +861,18 @@ public ThermalResistance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ThermalResistanceUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalResistanceUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index e098698fcc..ab2fd891e1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -1263,6 +1263,18 @@ public Torque ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not TorqueUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorqueUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index 52305910b6..1c230398b6 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -1179,6 +1179,18 @@ public TorquePerLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not TorquePerLengthUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorquePerLengthUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index aecd6d4db1..f4e8f29989 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -759,6 +759,18 @@ public Turbidity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not TurbidityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TurbidityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index 35032dd892..bdd6fade1e 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -756,6 +756,18 @@ public VitaminA ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not VitaminAUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VitaminAUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 41d8aef0a7..5d929b2385 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -1896,6 +1896,18 @@ public Volume ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not VolumeUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index bf7307c327..ecf7511ad6 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -1158,6 +1158,18 @@ public VolumeConcentration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not VolumeConcentrationUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeConcentrationUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index 42dbdbb521..77e4e4dc8a 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -2064,6 +2064,18 @@ public VolumeFlow ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not VolumeFlowUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs index 4492584d5b..8aeb0f5041 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs @@ -777,6 +777,18 @@ public VolumeFlowPerArea ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not VolumeFlowPerAreaUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowPerAreaUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index 5f65560339..edfa0d2122 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -882,6 +882,18 @@ public VolumePerLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not VolumePerLengthUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumePerLengthUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 2b169e34cc..f00234e5a9 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -927,6 +927,18 @@ public VolumetricHeatCapacity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not VolumetricHeatCapacityUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumetricHeatCapacityUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index a02331c0da..1eadff1253 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -861,6 +861,18 @@ public WarpingMomentOfInertia ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not WarpingMomentOfInertiaUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(WarpingMomentOfInertiaUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Units/ElectricChargeUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricChargeUnit.g.cs index c648f7fc82..bf853e9a10 100644 --- a/UnitsNet/GeneratedCode/Units/ElectricChargeUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ElectricChargeUnit.g.cs @@ -29,8 +29,8 @@ public enum ElectricChargeUnit Coulomb = 2, KiloampereHour = 3, Kilocoulomb = 13, - Megacoulomb = 6, MegaampereHour = 4, + Megacoulomb = 6, Microcoulomb = 11, MilliampereHour = 5, Millicoulomb = 7, diff --git a/UnitsNet/IValueQuantity.cs b/UnitsNet/IValueQuantity.cs index c94c282314..0b458787d1 100644 --- a/UnitsNet/IValueQuantity.cs +++ b/UnitsNet/IValueQuantity.cs @@ -48,5 +48,24 @@ public interface IValueQuantity : IQuantity /// The to convert the quantity value to. /// The converted value. new TValueType As(UnitSystem unitSystem); + + /// + /// Converts this to an in the given . + /// + /// + /// The unit value. The must be compatible with the units of the . + /// For example, if the is a , you should provide a value. + /// + /// Conversion was not possible from this to . + /// A new in the given . + new IValueQuantity ToUnit(Enum unit); + + /// + /// Converts to a quantity with a unit determined by the given , which affects things like . + /// If multiple units were found for the given , the first match will be used. + /// + /// The to convert the quantity to. + /// A new with the determined unit. + new IValueQuantity ToUnit(UnitSystem unitSystem); } } From 17427504f1db5b45acd6793597b06042e7d7cd76 Mon Sep 17 00:00:00 2001 From: Tristan Milnthorp Date: Mon, 13 Mar 2023 12:58:34 -0400 Subject: [PATCH 2/2] Use Information --- UnitsNet.Tests/IValueQuantityTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UnitsNet.Tests/IValueQuantityTests.cs b/UnitsNet.Tests/IValueQuantityTests.cs index bea6e392bb..a6379e33af 100644 --- a/UnitsNet.Tests/IValueQuantityTests.cs +++ b/UnitsNet.Tests/IValueQuantityTests.cs @@ -68,8 +68,8 @@ public void IValueQuantityTDouble_ToUnitUnitSystem_ReturnsIValueQuantityTDouble( [Fact] public void IValueQuantityTDecimal_ToUnitEnum_ReturnsIValueQuantityTDecimal() { - IValueQuantity decimalQuantity = Power.FromWatts(1234.5); - Assert.IsAssignableFrom>(decimalQuantity.ToUnit(PowerUnit.ElectricalHorsepower)); + IValueQuantity decimalQuantity = Information.FromKilobytes(1234.5); + Assert.IsAssignableFrom>(decimalQuantity.ToUnit(InformationUnit.Bit)); } [Fact]