From 8682ebd377308cc4ab5f5b3efab8e2a6c1eb7f12 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Fri, 24 Jul 2026 01:25:51 +0200 Subject: [PATCH] Move IQuantity conversion members to extensions --- .../UnitsNetGen/QuantityGenerator.cs | 26 +--- UnitsNet.Tests/CustomCode/IQuantityTests.cs | 53 ++++++- UnitsNet.Tests/CustomQuantities/HowMuch.cs | 22 --- UnitsNet/Extensions/QuantityExtensions.cs | 136 +++++++++++++++++- .../AbsorbedDoseOfIonizingRadiation.g.cs | 26 +--- .../Quantities/Acceleration.g.cs | 26 +--- .../Quantities/AmountOfSubstance.g.cs | 26 +--- .../Quantities/AmplitudeRatio.g.cs | 26 +--- UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 26 +--- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 26 +--- .../GeneratedCode/Quantities/AreaDensity.g.cs | 26 +--- .../Quantities/AreaMomentOfInertia.g.cs | 26 +--- .../Quantities/AreaPerLength.g.cs | 26 +--- .../GeneratedCode/Quantities/BitRate.g.cs | 26 +--- .../BrakeSpecificFuelConsumption.g.cs | 26 +--- .../CoefficientOfThermalExpansion.g.cs | 26 +--- .../Quantities/Compressibility.g.cs | 26 +--- .../GeneratedCode/Quantities/Density.g.cs | 26 +--- .../Quantities/DoseAreaProduct.g.cs | 26 +--- .../GeneratedCode/Quantities/Duration.g.cs | 26 +--- .../Quantities/DynamicViscosity.g.cs | 26 +--- .../Quantities/ElectricAdmittance.g.cs | 26 +--- .../Quantities/ElectricApparentEnergy.g.cs | 26 +--- .../Quantities/ElectricApparentPower.g.cs | 26 +--- .../Quantities/ElectricCapacitance.g.cs | 26 +--- .../Quantities/ElectricCharge.g.cs | 26 +--- .../Quantities/ElectricChargeDensity.g.cs | 26 +--- .../Quantities/ElectricConductance.g.cs | 26 +--- .../Quantities/ElectricConductivity.g.cs | 26 +--- .../Quantities/ElectricCurrent.g.cs | 26 +--- .../Quantities/ElectricCurrentDensity.g.cs | 26 +--- .../Quantities/ElectricCurrentGradient.g.cs | 26 +--- .../Quantities/ElectricField.g.cs | 26 +--- .../Quantities/ElectricImpedance.g.cs | 26 +--- .../Quantities/ElectricInductance.g.cs | 26 +--- .../Quantities/ElectricPotential.g.cs | 26 +--- .../ElectricPotentialChangeRate.g.cs | 26 +--- .../Quantities/ElectricReactance.g.cs | 26 +--- .../Quantities/ElectricReactiveEnergy.g.cs | 26 +--- .../Quantities/ElectricReactivePower.g.cs | 26 +--- .../Quantities/ElectricResistance.g.cs | 26 +--- .../Quantities/ElectricResistivity.g.cs | 26 +--- .../ElectricSurfaceChargeDensity.g.cs | 26 +--- .../Quantities/ElectricSusceptance.g.cs | 26 +--- UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 26 +--- .../Quantities/EnergyDensity.g.cs | 26 +--- .../GeneratedCode/Quantities/Entropy.g.cs | 26 +--- .../Quantities/FluidResistance.g.cs | 26 +--- UnitsNet/GeneratedCode/Quantities/Force.g.cs | 26 +--- .../Quantities/ForceChangeRate.g.cs | 26 +--- .../Quantities/ForcePerLength.g.cs | 26 +--- .../GeneratedCode/Quantities/Frequency.g.cs | 26 +--- .../Quantities/FuelEfficiency.g.cs | 26 +--- .../GeneratedCode/Quantities/HeatFlux.g.cs | 26 +--- .../Quantities/HeatTransferCoefficient.g.cs | 26 +--- .../GeneratedCode/Quantities/Illuminance.g.cs | 26 +--- .../GeneratedCode/Quantities/Impulse.g.cs | 26 +--- .../GeneratedCode/Quantities/Information.g.cs | 26 +--- .../GeneratedCode/Quantities/Irradiance.g.cs | 26 +--- .../GeneratedCode/Quantities/Irradiation.g.cs | 26 +--- UnitsNet/GeneratedCode/Quantities/Jerk.g.cs | 26 +--- .../Quantities/KinematicViscosity.g.cs | 26 +--- .../GeneratedCode/Quantities/LeakRate.g.cs | 26 +--- UnitsNet/GeneratedCode/Quantities/Length.g.cs | 26 +--- UnitsNet/GeneratedCode/Quantities/Level.g.cs | 26 +--- .../Quantities/LinearDensity.g.cs | 26 +--- .../Quantities/LinearPowerDensity.g.cs | 26 +--- .../GeneratedCode/Quantities/Luminance.g.cs | 26 +--- .../GeneratedCode/Quantities/Luminosity.g.cs | 26 +--- .../Quantities/LuminousFlux.g.cs | 26 +--- .../Quantities/LuminousIntensity.g.cs | 26 +--- .../Quantities/MagneticField.g.cs | 26 +--- .../Quantities/MagneticFlux.g.cs | 26 +--- .../Quantities/Magnetization.g.cs | 26 +--- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 26 +--- .../Quantities/MassConcentration.g.cs | 26 +--- .../GeneratedCode/Quantities/MassFlow.g.cs | 26 +--- .../GeneratedCode/Quantities/MassFlux.g.cs | 26 +--- .../Quantities/MassFraction.g.cs | 26 +--- .../Quantities/MassMomentOfInertia.g.cs | 26 +--- .../GeneratedCode/Quantities/Molality.g.cs | 26 +--- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 26 +--- .../Quantities/MolarEntropy.g.cs | 26 +--- .../GeneratedCode/Quantities/MolarFlow.g.cs | 26 +--- .../GeneratedCode/Quantities/MolarMass.g.cs | 26 +--- .../GeneratedCode/Quantities/Molarity.g.cs | 26 +--- .../Quantities/Permeability.g.cs | 26 +--- .../Quantities/Permittivity.g.cs | 26 +--- .../Quantities/PorousMediumPermeability.g.cs | 26 +--- UnitsNet/GeneratedCode/Quantities/Power.g.cs | 26 +--- .../Quantities/PowerDensity.g.cs | 26 +--- .../GeneratedCode/Quantities/PowerRatio.g.cs | 26 +--- .../GeneratedCode/Quantities/Pressure.g.cs | 26 +--- .../Quantities/PressureChangeRate.g.cs | 26 +--- .../Quantities/RadiationEquivalentDose.g.cs | 26 +--- .../RadiationEquivalentDoseRate.g.cs | 26 +--- .../Quantities/RadiationExposure.g.cs | 26 +--- .../Quantities/Radioactivity.g.cs | 26 +--- UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 26 +--- .../Quantities/RatioChangeRate.g.cs | 26 +--- .../Quantities/ReciprocalArea.g.cs | 26 +--- .../Quantities/ReciprocalLength.g.cs | 26 +--- .../Quantities/RelativeHumidity.g.cs | 26 +--- .../Quantities/RotationalAcceleration.g.cs | 26 +--- .../Quantities/RotationalSpeed.g.cs | 26 +--- .../Quantities/RotationalStiffness.g.cs | 26 +--- .../RotationalStiffnessPerLength.g.cs | 26 +--- UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 26 +--- .../GeneratedCode/Quantities/SolidAngle.g.cs | 26 +--- .../Quantities/SpecificEnergy.g.cs | 26 +--- .../Quantities/SpecificEntropy.g.cs | 26 +--- .../Quantities/SpecificFuelConsumption.g.cs | 26 +--- .../Quantities/SpecificVolume.g.cs | 26 +--- .../Quantities/SpecificWeight.g.cs | 26 +--- UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 26 +--- .../Quantities/StandardVolumeFlow.g.cs | 26 +--- .../GeneratedCode/Quantities/Temperature.g.cs | 26 +--- .../Quantities/TemperatureChangeRate.g.cs | 26 +--- .../Quantities/TemperatureDelta.g.cs | 26 +--- .../Quantities/TemperatureGradient.g.cs | 26 +--- .../Quantities/ThermalConductivity.g.cs | 26 +--- .../Quantities/ThermalInsulance.g.cs | 26 +--- .../Quantities/ThermalResistance.g.cs | 26 +--- UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 26 +--- .../GeneratedCode/Quantities/Turbidity.g.cs | 26 +--- .../GeneratedCode/Quantities/VitaminA.g.cs | 26 +--- UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 26 +--- .../Quantities/VolumeConcentration.g.cs | 26 +--- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 26 +--- .../Quantities/VolumeFlowPerArea.g.cs | 26 +--- .../Quantities/VolumePerLength.g.cs | 26 +--- .../Quantities/VolumetricHeatCapacity.g.cs | 26 +--- .../Quantities/WarpingMomentOfInertia.g.cs | 26 +--- UnitsNet/IQuantity.cs | 55 ------- 134 files changed, 312 insertions(+), 3334 deletions(-) diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index f6f2bf0496..227d2d6b06 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -1024,7 +1024,7 @@ public double As({_unitEnumName} unit) Writer.WL( $@" - /// + /// public double As(UnitKey unitKey) {{ return As(unitKey.ToUnit<{_unitEnumName}>()); @@ -1129,30 +1129,6 @@ private bool TryToUnit({_unitEnumName} unit, [NotNullWhen(true)] out {_quantity. }} "); Writer.WL($@" - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - }} - - /// - IQuantity IQuantity.ToUnit(Enum unit) - {{ - if (!(unit is {_unitEnumName} typedUnit)) - throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - }} - - /// - IQuantity<{_unitEnumName}> IQuantity<{_unitEnumName}>.ToUnit({_unitEnumName} unit) => ToUnit(unit); - - #endregion - #endregion "); } diff --git a/UnitsNet.Tests/CustomCode/IQuantityTests.cs b/UnitsNet.Tests/CustomCode/IQuantityTests.cs index 6ed292b617..6fd098c668 100644 --- a/UnitsNet.Tests/CustomCode/IQuantityTests.cs +++ b/UnitsNet.Tests/CustomCode/IQuantityTests.cs @@ -7,15 +7,60 @@ namespace UnitsNet.Tests; public partial class IQuantityTests { [Fact] - public void As_GivenWrongUnitType_ThrowsArgumentException() + public void As_GivenWrongUnitType_ThrowsUnitNotFoundException() { - Assert.All(Quantity.Infos.Select(x => x.Zero), quantity => { Assert.Throws(() => quantity.As(ComparisonType.Absolute)); }); + Assert.All(Quantity.Infos.Select(x => x.Zero), quantity => { Assert.Throws(() => quantity.As(ComparisonType.Absolute)); }); } [Fact] - public void ToUnit_GivenWrongUnitType_ThrowsArgumentException() + public void ToUnit_GivenWrongUnitType_ThrowsUnitNotFoundException() { - Assert.All(Quantity.Infos.Select(x => x.Zero), quantity => { Assert.Throws(() => quantity.ToUnit(ComparisonType.Absolute)); }); + Assert.All(Quantity.Infos.Select(x => x.Zero), + quantity => { Assert.Throws(() => quantity.ToUnit(ComparisonType.Absolute)); }); + } + + [Fact] + public void As_InterfaceReferences_ReturnConvertedValue() + { + var mass = Mass.FromKilograms(1); + IQuantity quantity = mass; + IQuantity typedQuantity = mass; + + Assert.Equal(1000, quantity.As(MassUnit.Gram)); + Assert.Equal(1000, typedQuantity.As(MassUnit.Gram)); + } + + [Fact] + public void ToUnit_IQuantityFromNonBaseUnit_ReturnsConvertedQuantity() + { + IQuantity quantity = Length.FromKilometers(1); + + IQuantity convertedQuantity = quantity.ToUnit(LengthUnit.Centimeter); + + Assert.Equal(100_000, convertedQuantity.Value); + Assert.Equal(LengthUnit.Centimeter, convertedQuantity.Unit); + } + + [Fact] + public void ToUnit_GenericConstraintWithCustomConverter_UsesProvidedConverter() + { + var converter = new UnitConverter(); + converter.SetConversionFunction( + LengthUnit.Meter, + LengthUnit.Centimeter, + _ => Length.FromCentimeters(123)); + + Length convertedQuantity = ConvertToUnit(Length.FromMeters(1), LengthUnit.Centimeter, converter); + + Assert.Equal(123, convertedQuantity.Value); + Assert.Equal(LengthUnit.Centimeter, convertedQuantity.Unit); + + static TQuantity ConvertToUnit(TQuantity quantity, TUnit unit, UnitConverter unitConverter) + where TQuantity : IQuantity + where TUnit : struct, Enum + { + return quantity.ToUnit(unit, unitConverter); + } } [Fact] diff --git a/UnitsNet.Tests/CustomQuantities/HowMuch.cs b/UnitsNet.Tests/CustomQuantities/HowMuch.cs index 99641b0553..99058b71b8 100644 --- a/UnitsNet.Tests/CustomQuantities/HowMuch.cs +++ b/UnitsNet.Tests/CustomQuantities/HowMuch.cs @@ -20,11 +20,6 @@ public static HowMuch From(double value, HowMuchUnit unit) return new HowMuch(value, unit); } - public double As(HowMuchUnit unit) - { - throw new NotImplementedException(); - } - public HowMuchUnit Unit { get; } public double Value { get; } @@ -64,23 +59,6 @@ UnitKey IQuantity.UnitKey get => UnitKey.ForUnit(Unit); } - public double As(Enum unit) => Convert.ToDouble(unit); - public double As(UnitKey unitKey) - { - return As(unitKey.ToUnit()); - } - - public IQuantity ToUnit(Enum unit) - { - if (unit is HowMuchUnit howMuchUnit) return new HowMuch(As(unit), howMuchUnit); - throw new ArgumentException("Must be of type HowMuchUnit.", nameof(unit)); - } - - public IQuantity ToUnit(HowMuchUnit unit) - { - throw new NotImplementedException(); - } - public override string ToString() { return $"{Value} {Unit}"; diff --git a/UnitsNet/Extensions/QuantityExtensions.cs b/UnitsNet/Extensions/QuantityExtensions.cs index 56ca36ae85..1edbf05007 100644 --- a/UnitsNet/Extensions/QuantityExtensions.cs +++ b/UnitsNet/Extensions/QuantityExtensions.cs @@ -78,12 +78,142 @@ public static UnitInfo GetUnitInfo(this IQua #endif } - /// - /// This should be using UnitConverter.Default.ConvertValue(quantity, toUnit) + private static IQuantity ConvertTo(this UnitConverter converter, IQuantity quantity, UnitKey toUnit) + { + if (quantity.UnitKey == toUnit) + { + return quantity; + } + + var targetUnit = (Enum)toUnit; + Type quantityType = quantity.GetType(); + if (converter.TryGetConversionFunction(quantityType, quantity.Unit, quantityType, targetUnit, out ConversionFunction? conversionFunction)) + { + return conversionFunction(quantity); + } + +#pragma warning disable CS0618 // Type or member is obsolete + UnitKey baseUnit = quantity.QuantityInfo.BaseUnitInfo.UnitKey; +#pragma warning restore CS0618 // Type or member is obsolete + if (quantity.UnitKey != baseUnit) + { + IQuantity quantityInBaseUnit = converter.ConvertTo(quantity, baseUnit); + return converter.ConvertTo(quantityInBaseUnit, toUnit); + } + + throw new UnitNotFoundException($"Can't convert {quantity.Unit} to {targetUnit}."); + } + + /// + /// Converts a quantity value to the specified unit. + /// + /// The converter to use. + /// The quantity to convert. + /// The target unit. + /// The converted value. + internal static double ConvertValue(this UnitConverter converter, TQuantity quantity, UnitKey toUnit) + where TQuantity : IQuantity + { + return converter.ConvertTo(quantity, toUnit).Value; + } + + /// + /// Converts a quantity to the specified unit while preserving its concrete type. + /// + /// The converter to use. + /// The quantity to convert. + /// The target unit. + /// The converted quantity. + internal static TQuantity ConvertToUnit(this UnitConverter converter, TQuantity quantity, UnitKey toUnit) + where TQuantity : IQuantityOfType + { + return (TQuantity)converter.ConvertTo(quantity, toUnit); + } + + /// + /// Gets the value of a quantity in the specified unit. + /// internal static double GetValue(this TQuantity quantity, UnitKey toUnit) where TQuantity : IQuantity { - return quantity.As(toUnit); + return UnitConverter.Default.ConvertValue(quantity, toUnit); + } + + /// + /// Gets the value of a quantity in the specified unit. + /// + /// The quantity type. + /// The unit enum type. + /// The quantity to convert. + /// The target unit. + /// The converted value. + public static double As(this TQuantity quantity, TUnit unit) + where TQuantity : IQuantity + where TUnit : struct, Enum + { + return UnitConverter.Default.ConvertValue(quantity, UnitKey.ForUnit(unit)); + } + + /// + /// Gets the value of a quantity in the specified unit. + /// + /// The quantity to convert. + /// The target unit. + /// The converted value. + public static double As(this IQuantity quantity, UnitKey unit) + { + return UnitConverter.Default.ConvertValue(quantity, unit); + } + + /// + /// Converts a quantity to the specified unit while preserving its concrete type. + /// + /// The quantity type. + /// The unit enum type. + /// The quantity to convert. + /// The target unit. + /// The converted quantity. + public static TQuantity ToUnit(this TQuantity quantity, TUnit unit) + where TQuantity : IQuantity + where TUnit : struct, Enum + { + return quantity.ToUnit(unit, UnitConverter.Default); + } + + /// + /// The quantity to convert. + /// The target unit. + /// The converter to use. + public static TQuantity ToUnit(this TQuantity quantity, TUnit unit, UnitConverter unitConverter) + where TQuantity : IQuantity + where TUnit : struct, Enum + { + if (unitConverter is null) throw new ArgumentNullException(nameof(unitConverter)); + return unitConverter.ConvertToUnit(quantity, UnitKey.ForUnit(unit)); + } + + /// + /// Converts a quantity to the specified unit. + /// + /// The quantity to convert. + /// The target unit. + /// The converted quantity. + public static IQuantity ToUnit(this IQuantity quantity, UnitKey unit) + { + return UnitConverter.Default.ConvertTo(quantity, unit); + } + + /// + /// Converts a quantity to the specified unit. + /// + /// The unit enum type. + /// The quantity to convert. + /// The target unit. + /// The converted quantity. + public static IQuantity ToUnit(this IQuantity quantity, TUnit unit) + where TUnit : struct, Enum + { + return (IQuantity)UnitConverter.Default.ConvertTo(quantity, UnitKey.ForUnit(unit)); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs b/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs index d289e69141..77eb332c53 100644 --- a/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs @@ -867,7 +867,7 @@ public double As(AbsorbedDoseOfIonizingRadiationUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -979,30 +979,6 @@ private bool TryToUnit(AbsorbedDoseOfIonizingRadiationUnit unit, [NotNullWhen(tr return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not AbsorbedDoseOfIonizingRadiationUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AbsorbedDoseOfIonizingRadiationUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is AbsorbedDoseOfIonizingRadiationUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AbsorbedDoseOfIonizingRadiationUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(AbsorbedDoseOfIonizingRadiationUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 234c7e2265..445b6034d2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -869,7 +869,7 @@ public double As(AccelerationUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -975,30 +975,6 @@ private bool TryToUnit(AccelerationUnit unit, [NotNullWhen(true)] out Accelerati return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is AccelerationUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AccelerationUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(AccelerationUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 4530d4fef1..8ce7158358 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -910,7 +910,7 @@ public double As(AmountOfSubstanceUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1022,30 +1022,6 @@ private bool TryToUnit(AmountOfSubstanceUnit unit, [NotNullWhen(true)] out Amoun return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is AmountOfSubstanceUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmountOfSubstanceUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(AmountOfSubstanceUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index 0db3066f16..234cc32009 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -657,7 +657,7 @@ public double As(AmplitudeRatioUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -743,30 +743,6 @@ private bool TryToUnit(AmplitudeRatioUnit unit, [NotNullWhen(true)] out Amplitud return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is AmplitudeRatioUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmplitudeRatioUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(AmplitudeRatioUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index cea2892db8..766306e78a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -843,7 +843,7 @@ public double As(AngleUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -951,30 +951,6 @@ private bool TryToUnit(AngleUnit unit, [NotNullWhen(true)] out Angle? converted) return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is AngleUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AngleUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(AngleUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 4c97cd7e43..0347b52396 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -946,7 +946,7 @@ public double As(AreaUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1052,30 +1052,6 @@ private bool TryToUnit(AreaUnit unit, [NotNullWhen(true)] out Area? converted) return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is AreaUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(AreaUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index 4b601d0d7b..4aa15d2020 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -711,7 +711,7 @@ public double As(AreaDensityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -799,30 +799,6 @@ private bool TryToUnit(AreaDensityUnit unit, [NotNullWhen(true)] out AreaDensity return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is AreaDensityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaDensityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(AreaDensityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 139d53c57c..9fce10b408 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -713,7 +713,7 @@ public double As(AreaMomentOfInertiaUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -803,30 +803,6 @@ private bool TryToUnit(AreaMomentOfInertiaUnit unit, [NotNullWhen(true)] out Are return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is AreaMomentOfInertiaUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaMomentOfInertiaUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(AreaMomentOfInertiaUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/AreaPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaPerLength.g.cs index c65410d55c..b92b18a527 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaPerLength.g.cs @@ -699,7 +699,7 @@ public double As(AreaPerLengthUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -789,30 +789,6 @@ private bool TryToUnit(AreaPerLengthUnit unit, [NotNullWhen(true)] out AreaPerLe return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not AreaPerLengthUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaPerLengthUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is AreaPerLengthUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaPerLengthUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(AreaPerLengthUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index 818cfb5660..b56d49883f 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -1219,7 +1219,7 @@ public double As(BitRateUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1375,30 +1375,6 @@ private bool TryToUnit(BitRateUnit unit, [NotNullWhen(true)] out BitRate? conver return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is BitRateUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BitRateUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(BitRateUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 0712ae2f68..893d097c69 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -664,7 +664,7 @@ public double As(BrakeSpecificFuelConsumptionUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -748,30 +748,6 @@ private bool TryToUnit(BrakeSpecificFuelConsumptionUnit unit, [NotNullWhen(true) return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is BrakeSpecificFuelConsumptionUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BrakeSpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(BrakeSpecificFuelConsumptionUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index e089f98518..8681802ec9 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -699,7 +699,7 @@ public double As(CoefficientOfThermalExpansionUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -789,30 +789,6 @@ private bool TryToUnit(CoefficientOfThermalExpansionUnit unit, [NotNullWhen(true return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is CoefficientOfThermalExpansionUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CoefficientOfThermalExpansionUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(CoefficientOfThermalExpansionUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs index 6913b3a5fa..c7634fa2ef 100644 --- a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs @@ -704,7 +704,7 @@ public double As(CompressibilityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -796,30 +796,6 @@ private bool TryToUnit(CompressibilityUnit unit, [NotNullWhen(true)] out Compres return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is CompressibilityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CompressibilityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(CompressibilityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 9c91a1f337..15893d1f74 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -1558,7 +1558,7 @@ public double As(DensityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1748,30 +1748,6 @@ private bool TryToUnit(DensityUnit unit, [NotNullWhen(true)] out Density? conver return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is DensityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DensityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(DensityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs b/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs index f6b774c5a6..5e49b5e30b 100644 --- a/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs @@ -995,7 +995,7 @@ public double As(DoseAreaProductUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1123,30 +1123,6 @@ private bool TryToUnit(DoseAreaProductUnit unit, [NotNullWhen(true)] out DoseAre return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not DoseAreaProductUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DoseAreaProductUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is DoseAreaProductUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DoseAreaProductUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(DoseAreaProductUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index f8ab8fb0b1..2ed6aec1c4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -909,7 +909,7 @@ public double As(DurationUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1013,30 +1013,6 @@ private bool TryToUnit(DurationUnit unit, [NotNullWhen(true)] out Duration? conv return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is DurationUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DurationUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(DurationUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index c9bb82381a..0721e509b0 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -773,7 +773,7 @@ public double As(DynamicViscosityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -871,30 +871,6 @@ private bool TryToUnit(DynamicViscosityUnit unit, [NotNullWhen(true)] out Dynami return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is DynamicViscosityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DynamicViscosityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(DynamicViscosityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 2c73e10db8..a5cf511858 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -852,7 +852,7 @@ public double As(ElectricAdmittanceUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -962,30 +962,6 @@ private bool TryToUnit(ElectricAdmittanceUnit unit, [NotNullWhen(true)] out Elec return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricAdmittanceUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricAdmittanceUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricAdmittanceUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs index 8862908d3a..b25622f7be 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs @@ -640,7 +640,7 @@ public double As(ElectricApparentEnergyUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -724,30 +724,6 @@ private bool TryToUnit(ElectricApparentEnergyUnit unit, [NotNullWhen(true)] out return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not ElectricApparentEnergyUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricApparentEnergyUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricApparentEnergyUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricApparentEnergyUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricApparentEnergyUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs index 8ea03545e8..aebc5cd178 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs @@ -691,7 +691,7 @@ public double As(ElectricApparentPowerUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -781,30 +781,6 @@ private bool TryToUnit(ElectricApparentPowerUnit unit, [NotNullWhen(true)] out E return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not ElectricApparentPowerUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricApparentPowerUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricApparentPowerUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricApparentPowerUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricApparentPowerUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs index 23e11dcc23..bb6062d518 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs @@ -707,7 +707,7 @@ public double As(ElectricCapacitanceUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -799,30 +799,6 @@ private bool TryToUnit(ElectricCapacitanceUnit unit, [NotNullWhen(true)] out Ele return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not ElectricCapacitanceUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCapacitanceUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricCapacitanceUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCapacitanceUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricCapacitanceUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index a1e0889a9e..6576034c1b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -796,7 +796,7 @@ public double As(ElectricChargeUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -896,30 +896,6 @@ private bool TryToUnit(ElectricChargeUnit unit, [NotNullWhen(true)] out Electric return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricChargeUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricChargeUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 4e05e910d1..faad9c5866 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -611,7 +611,7 @@ public double As(ElectricChargeDensityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -691,30 +691,6 @@ private bool TryToUnit(ElectricChargeDensityUnit unit, [NotNullWhen(true)] out E return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricChargeDensityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeDensityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricChargeDensityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index 65754fc494..57fafb95de 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -851,7 +851,7 @@ public double As(ElectricConductanceUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -961,30 +961,6 @@ private bool TryToUnit(ElectricConductanceUnit unit, [NotNullWhen(true)] out Ele return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricConductanceUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductanceUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricConductanceUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index b3d2d58156..7efd468f4e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -702,7 +702,7 @@ public double As(ElectricConductivityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -792,30 +792,6 @@ private bool TryToUnit(ElectricConductivityUnit unit, [NotNullWhen(true)] out El return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricConductivityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductivityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricConductivityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index a331f270bb..497755cc74 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -778,7 +778,7 @@ public double As(ElectricCurrentUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -874,30 +874,6 @@ private bool TryToUnit(ElectricCurrentUnit unit, [NotNullWhen(true)] out Electri return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricCurrentUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricCurrentUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index 3be252f536..20cb61261b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -643,7 +643,7 @@ public double As(ElectricCurrentDensityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -727,30 +727,6 @@ private bool TryToUnit(ElectricCurrentDensityUnit unit, [NotNullWhen(true)] out return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricCurrentDensityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentDensityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricCurrentDensityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index 1280573afa..b5e5db4df3 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -715,7 +715,7 @@ public double As(ElectricCurrentGradientUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -807,30 +807,6 @@ private bool TryToUnit(ElectricCurrentGradientUnit unit, [NotNullWhen(true)] out return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricCurrentGradientUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentGradientUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricCurrentGradientUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index bd9198ec6a..7248325221 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -611,7 +611,7 @@ public double As(ElectricFieldUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -691,30 +691,6 @@ private bool TryToUnit(ElectricFieldUnit unit, [NotNullWhen(true)] out ElectricF return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricFieldUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricFieldUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricFieldUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs index 9bfc7824bd..cf96f1d46c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs @@ -724,7 +724,7 @@ public double As(ElectricImpedanceUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -818,30 +818,6 @@ private bool TryToUnit(ElectricImpedanceUnit unit, [NotNullWhen(true)] out Elect return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not ElectricImpedanceUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricImpedanceUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricImpedanceUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricImpedanceUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricImpedanceUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index ca4bb64b35..1f6e9dba86 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -675,7 +675,7 @@ public double As(ElectricInductanceUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -763,30 +763,6 @@ private bool TryToUnit(ElectricInductanceUnit unit, [NotNullWhen(true)] out Elec return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricInductanceUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricInductanceUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricInductanceUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index c967748047..58622dfb77 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -723,7 +723,7 @@ public double As(ElectricPotentialUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -813,30 +813,6 @@ private bool TryToUnit(ElectricPotentialUnit unit, [NotNullWhen(true)] out Elect return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricPotentialUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricPotentialUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index f260c75ae9..ca0cc9092f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -912,7 +912,7 @@ public double As(ElectricPotentialChangeRateUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1030,30 +1030,6 @@ private bool TryToUnit(ElectricPotentialChangeRateUnit unit, [NotNullWhen(true)] return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricPotentialChangeRateUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialChangeRateUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricPotentialChangeRateUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs index f95fa43575..dbc88dd504 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs @@ -723,7 +723,7 @@ public double As(ElectricReactanceUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -817,30 +817,6 @@ private bool TryToUnit(ElectricReactanceUnit unit, [NotNullWhen(true)] out Elect return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not ElectricReactanceUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricReactanceUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricReactanceUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricReactanceUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricReactanceUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs index 2de46419a9..fc20496b12 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs @@ -640,7 +640,7 @@ public double As(ElectricReactiveEnergyUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -724,30 +724,6 @@ private bool TryToUnit(ElectricReactiveEnergyUnit unit, [NotNullWhen(true)] out return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not ElectricReactiveEnergyUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricReactiveEnergyUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricReactiveEnergyUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricReactiveEnergyUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricReactiveEnergyUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs index ce85f123d2..0770e7eb3d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs @@ -659,7 +659,7 @@ public double As(ElectricReactivePowerUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -745,30 +745,6 @@ private bool TryToUnit(ElectricReactivePowerUnit unit, [NotNullWhen(true)] out E return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not ElectricReactivePowerUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricReactivePowerUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricReactivePowerUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricReactivePowerUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricReactivePowerUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index 0ea2926dff..1f324aebe4 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -734,7 +734,7 @@ public double As(ElectricResistanceUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -828,30 +828,6 @@ private bool TryToUnit(ElectricResistanceUnit unit, [NotNullWhen(true)] out Elec return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricResistanceUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistanceUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricResistanceUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index 08b3034f2f..2a4a34bebe 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -830,7 +830,7 @@ public double As(ElectricResistivityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -936,30 +936,6 @@ private bool TryToUnit(ElectricResistivityUnit unit, [NotNullWhen(true)] out Ele return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricResistivityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistivityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricResistivityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index dc490b390b..9c94bd6b0d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -643,7 +643,7 @@ public double As(ElectricSurfaceChargeDensityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -727,30 +727,6 @@ private bool TryToUnit(ElectricSurfaceChargeDensityUnit unit, [NotNullWhen(true) return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricSurfaceChargeDensityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricSurfaceChargeDensityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricSurfaceChargeDensityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs index d1dd42d07f..df9851204a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs @@ -851,7 +851,7 @@ public double As(ElectricSusceptanceUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -961,30 +961,6 @@ private bool TryToUnit(ElectricSusceptanceUnit unit, [NotNullWhen(true)] out Ele return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not ElectricSusceptanceUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricSusceptanceUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ElectricSusceptanceUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricSusceptanceUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ElectricSusceptanceUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index 6e3e1a04bf..f3d3627d32 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -1327,7 +1327,7 @@ public double As(EnergyUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1485,30 +1485,6 @@ private bool TryToUnit(EnergyUnit unit, [NotNullWhen(true)] out Energy? converte return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is EnergyUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EnergyUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(EnergyUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs index da2d4b638c..a56bb210f8 100644 --- a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs @@ -795,7 +795,7 @@ public double As(EnergyDensityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -897,30 +897,6 @@ private bool TryToUnit(EnergyDensityUnit unit, [NotNullWhen(true)] out EnergyDen return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is EnergyDensityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EnergyDensityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(EnergyDensityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index e1e1545fc6..d780ee3cba 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -729,7 +729,7 @@ public double As(EntropyUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -821,30 +821,6 @@ private bool TryToUnit(EntropyUnit unit, [NotNullWhen(true)] out Entropy? conver return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is EntropyUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EntropyUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(EntropyUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs index b7d8f55957..22b2504e3f 100644 --- a/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs @@ -899,7 +899,7 @@ public double As(FluidResistanceUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1015,30 +1015,6 @@ private bool TryToUnit(FluidResistanceUnit unit, [NotNullWhen(true)] out FluidRe return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not FluidResistanceUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FluidResistanceUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is FluidResistanceUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FluidResistanceUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(FluidResistanceUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 905b672b4a..bb9104bc02 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -950,7 +950,7 @@ public double As(ForceUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1060,30 +1060,6 @@ private bool TryToUnit(ForceUnit unit, [NotNullWhen(true)] out Force? converted) return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ForceUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ForceUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index 37ef54fe3f..469ecafdcb 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -843,7 +843,7 @@ public double As(ForceChangeRateUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -951,30 +951,6 @@ private bool TryToUnit(ForceChangeRateUnit unit, [NotNullWhen(true)] out ForceCh return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ForceChangeRateUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceChangeRateUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ForceChangeRateUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index 2749cdb6a7..5128cdb7ea 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -1281,7 +1281,7 @@ public double As(ForcePerLengthUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1435,30 +1435,6 @@ private bool TryToUnit(ForcePerLengthUnit unit, [NotNullWhen(true)] out ForcePer return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ForcePerLengthUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForcePerLengthUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ForcePerLengthUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index ca09928825..f0d46a9591 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -795,7 +795,7 @@ public double As(FrequencyUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -897,30 +897,6 @@ private bool TryToUnit(FrequencyUnit unit, [NotNullWhen(true)] out Frequency? co return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is FrequencyUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FrequencyUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(FrequencyUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index d1e24ea670..4e28cd5ab1 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -659,7 +659,7 @@ public double As(FuelEfficiencyUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -745,30 +745,6 @@ private bool TryToUnit(FuelEfficiencyUnit unit, [NotNullWhen(true)] out FuelEffi return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is FuelEfficiencyUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FuelEfficiencyUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(FuelEfficiencyUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index bec79ebf22..4d3cb3c319 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -1003,7 +1003,7 @@ public double As(HeatFluxUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1131,30 +1131,6 @@ private bool TryToUnit(HeatFluxUnit unit, [NotNullWhen(true)] out HeatFlux? conv return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is HeatFluxUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatFluxUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(HeatFluxUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 971fe171a0..4c4be043b7 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -688,7 +688,7 @@ public double As(HeatTransferCoefficientUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -778,30 +778,6 @@ private bool TryToUnit(HeatTransferCoefficientUnit unit, [NotNullWhen(true)] out return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is HeatTransferCoefficientUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatTransferCoefficientUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(HeatTransferCoefficientUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index 46a8c6dbef..c048db2e45 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -670,7 +670,7 @@ public double As(IlluminanceUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -756,30 +756,6 @@ private bool TryToUnit(IlluminanceUnit unit, [NotNullWhen(true)] out Illuminance return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is IlluminanceUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IlluminanceUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(IlluminanceUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs index d235d81c4f..2ea43d20ff 100644 --- a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs @@ -800,7 +800,7 @@ public double As(ImpulseUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -904,30 +904,6 @@ private bool TryToUnit(ImpulseUnit unit, [NotNullWhen(true)] out Impulse? conver return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ImpulseUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ImpulseUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ImpulseUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 396b29890f..5a90545f58 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -1202,7 +1202,7 @@ public double As(InformationUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1358,30 +1358,6 @@ private bool TryToUnit(InformationUnit unit, [NotNullWhen(true)] out Information return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is InformationUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(InformationUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(InformationUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index 05f5023fca..158c788ad1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -816,7 +816,7 @@ public double As(IrradianceUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -922,30 +922,6 @@ private bool TryToUnit(IrradianceUnit unit, [NotNullWhen(true)] out Irradiance? return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is IrradianceUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradianceUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(IrradianceUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index 66653eecf9..d9b87ede73 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -739,7 +739,7 @@ public double As(IrradiationUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -835,30 +835,6 @@ private bool TryToUnit(IrradiationUnit unit, [NotNullWhen(true)] out Irradiation return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is IrradiationUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradiationUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(IrradiationUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs index 82f1e4f09d..3cea22d839 100644 --- a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs @@ -779,7 +779,7 @@ public double As(JerkUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -879,30 +879,6 @@ private bool TryToUnit(JerkUnit unit, [NotNullWhen(true)] out Jerk? converted) return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is JerkUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(JerkUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(JerkUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 020c44f495..56b9f970c6 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -771,7 +771,7 @@ public double As(KinematicViscosityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -867,30 +867,6 @@ private bool TryToUnit(KinematicViscosityUnit unit, [NotNullWhen(true)] out Kine return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is KinematicViscosityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(KinematicViscosityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(KinematicViscosityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs index 0c348471bc..3d7240a0a3 100644 --- a/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs @@ -659,7 +659,7 @@ public double As(LeakRateUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -745,30 +745,6 @@ private bool TryToUnit(LeakRateUnit unit, [NotNullWhen(true)] out LeakRate? conv return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not LeakRateUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LeakRateUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is LeakRateUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LeakRateUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(LeakRateUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index 414fe3f789..048fa618a6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -1422,7 +1422,7 @@ public double As(LengthUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1584,30 +1584,6 @@ private bool TryToUnit(LengthUnit unit, [NotNullWhen(true)] out Length? converte return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is LengthUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LengthUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(LengthUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index e7bb8464fc..ba08eaf247 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -625,7 +625,7 @@ public double As(LevelUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -707,30 +707,6 @@ private bool TryToUnit(LevelUnit unit, [NotNullWhen(true)] out Level? converted) return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is LevelUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LevelUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(LevelUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 3fc8d62ed5..a092415240 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -929,7 +929,7 @@ public double As(LinearDensityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1043,30 +1043,6 @@ private bool TryToUnit(LinearDensityUnit unit, [NotNullWhen(true)] out LinearDen return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is LinearDensityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearDensityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(LinearDensityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index c21d2bfad6..2723f35fcb 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -995,7 +995,7 @@ public double As(LinearPowerDensityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1123,30 +1123,6 @@ private bool TryToUnit(LinearPowerDensityUnit unit, [NotNullWhen(true)] out Line return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is LinearPowerDensityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearPowerDensityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(LinearPowerDensityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs index e4e5427444..c1972ea16e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs @@ -766,7 +766,7 @@ public double As(LuminanceUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -864,30 +864,6 @@ private bool TryToUnit(LuminanceUnit unit, [NotNullWhen(true)] out Luminance? co return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is LuminanceUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminanceUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(LuminanceUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index fa05cd6d8b..77d93c9402 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -819,7 +819,7 @@ public double As(LuminosityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -925,30 +925,6 @@ private bool TryToUnit(LuminosityUnit unit, [NotNullWhen(true)] out Luminosity? return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is LuminosityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminosityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(LuminosityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index 68c29ad4c7..314a6085e6 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -629,7 +629,7 @@ public double As(LuminousFluxUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -709,30 +709,6 @@ private bool TryToUnit(LuminousFluxUnit unit, [NotNullWhen(true)] out LuminousFl return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is LuminousFluxUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousFluxUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(LuminousFluxUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index 09c340b3e2..00718ad4c8 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -629,7 +629,7 @@ public double As(LuminousIntensityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -709,30 +709,6 @@ private bool TryToUnit(LuminousIntensityUnit unit, [NotNullWhen(true)] out Lumin return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is LuminousIntensityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousIntensityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(LuminousIntensityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index d0eb1a8951..6bcb0331a4 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -691,7 +691,7 @@ public double As(MagneticFieldUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -781,30 +781,6 @@ private bool TryToUnit(MagneticFieldUnit unit, [NotNullWhen(true)] out MagneticF return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is MagneticFieldUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFieldUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(MagneticFieldUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index 1c2c629fb6..f47e248f44 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -611,7 +611,7 @@ public double As(MagneticFluxUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -691,30 +691,6 @@ private bool TryToUnit(MagneticFluxUnit unit, [NotNullWhen(true)] out MagneticFl return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is MagneticFluxUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFluxUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(MagneticFluxUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index 806958dec8..e70c7c1876 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -611,7 +611,7 @@ public double As(MagnetizationUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -691,30 +691,6 @@ private bool TryToUnit(MagnetizationUnit unit, [NotNullWhen(true)] out Magnetiza return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is MagnetizationUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagnetizationUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(MagnetizationUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index c6596c311d..560f31c220 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -1204,7 +1204,7 @@ public double As(MassUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1344,30 +1344,6 @@ private bool TryToUnit(MassUnit unit, [NotNullWhen(true)] out Mass? converted) return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is MassUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(MassUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index 0d57d2b4c7..9432eef0e1 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -1418,7 +1418,7 @@ public double As(MassConcentrationUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1594,30 +1594,6 @@ private bool TryToUnit(MassConcentrationUnit unit, [NotNullWhen(true)] out MassC return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is MassConcentrationUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassConcentrationUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(MassConcentrationUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index fd5fc83419..e97f523100 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -1194,7 +1194,7 @@ public double As(MassFlowUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1338,30 +1338,6 @@ private bool TryToUnit(MassFlowUnit unit, [NotNullWhen(true)] out MassFlow? conv return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is MassFlowUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFlowUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(MassFlowUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index dbe90db2d0..23541133d4 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -809,7 +809,7 @@ public double As(MassFluxUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -911,30 +911,6 @@ private bool TryToUnit(MassFluxUnit unit, [NotNullWhen(true)] out MassFlux? conv return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is MassFluxUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFluxUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(MassFluxUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 0f9082e482..b50e25507b 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -976,7 +976,7 @@ public double As(MassFractionUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1102,30 +1102,6 @@ private bool TryToUnit(MassFractionUnit unit, [NotNullWhen(true)] out MassFracti return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is MassFractionUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFractionUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(MassFractionUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index ac2b1c4b20..1197a6cf56 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -1040,7 +1040,7 @@ public double As(MassMomentOfInertiaUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1174,30 +1174,6 @@ private bool TryToUnit(MassMomentOfInertiaUnit unit, [NotNullWhen(true)] out Mas return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is MassMomentOfInertiaUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassMomentOfInertiaUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(MassMomentOfInertiaUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Molality.g.cs b/UnitsNet/GeneratedCode/Quantities/Molality.g.cs index fed53e3f90..667b8ab27a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molality.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molality.g.cs @@ -643,7 +643,7 @@ public double As(MolalityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -727,30 +727,6 @@ private bool TryToUnit(MolalityUnit unit, [NotNullWhen(true)] out Molality? conv return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not MolalityUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolalityUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is MolalityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolalityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(MolalityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index 2163c71c7e..b8cd5d6c54 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -651,7 +651,7 @@ public double As(MolarEnergyUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -735,30 +735,6 @@ private bool TryToUnit(MolarEnergyUnit unit, [NotNullWhen(true)] out MolarEnergy return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is MolarEnergyUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEnergyUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(MolarEnergyUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index f807a2151c..e67cdee1d6 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -640,7 +640,7 @@ public double As(MolarEntropyUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -724,30 +724,6 @@ private bool TryToUnit(MolarEntropyUnit unit, [NotNullWhen(true)] out MolarEntro return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is MolarEntropyUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEntropyUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(MolarEntropyUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs index 0890875ce5..2920cd38a2 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs @@ -768,7 +768,7 @@ public double As(MolarFlowUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -864,30 +864,6 @@ private bool TryToUnit(MolarFlowUnit unit, [NotNullWhen(true)] out MolarFlow? co return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is MolarFlowUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarFlowUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(MolarFlowUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 8427543dba..b21fd6678d 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -825,7 +825,7 @@ public double As(MolarMassUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -929,30 +929,6 @@ private bool TryToUnit(MolarMassUnit unit, [NotNullWhen(true)] out MolarMass? co return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is MolarMassUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarMassUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(MolarMassUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index d088f1c271..3c7696d115 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -810,7 +810,7 @@ public double As(MolarityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -910,30 +910,6 @@ private bool TryToUnit(MolarityUnit unit, [NotNullWhen(true)] out Molarity? conv return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is MolarityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(MolarityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index 4bd8abcca2..d2351437fb 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -611,7 +611,7 @@ public double As(PermeabilityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -691,30 +691,6 @@ private bool TryToUnit(PermeabilityUnit unit, [NotNullWhen(true)] out Permeabili return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is PermeabilityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermeabilityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(PermeabilityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index 43da8ffd91..e2ba2c1b3b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -611,7 +611,7 @@ public double As(PermittivityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -691,30 +691,6 @@ private bool TryToUnit(PermittivityUnit unit, [NotNullWhen(true)] out Permittivi return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is PermittivityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermittivityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(PermittivityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs index 3137b1a506..fccab8a914 100644 --- a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs @@ -675,7 +675,7 @@ public double As(PorousMediumPermeabilityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -763,30 +763,6 @@ private bool TryToUnit(PorousMediumPermeabilityUnit unit, [NotNullWhen(true)] ou return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is PorousMediumPermeabilityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PorousMediumPermeabilityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(PorousMediumPermeabilityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index fb9282c12c..194ff8f6f5 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -1126,7 +1126,7 @@ public double As(PowerUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1258,30 +1258,6 @@ private bool TryToUnit(PowerUnit unit, [NotNullWhen(true)] out Power? converted) return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is PowerUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(PowerUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index 6186ca7f46..6f5abf8f7d 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -1328,7 +1328,7 @@ public double As(PowerDensityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1498,30 +1498,6 @@ private bool TryToUnit(PowerDensityUnit unit, [NotNullWhen(true)] out PowerDensi return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is PowerDensityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerDensityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(PowerDensityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index eee3ae332b..0b0670f34f 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -625,7 +625,7 @@ public double As(PowerRatioUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -707,30 +707,6 @@ private bool TryToUnit(PowerRatioUnit unit, [NotNullWhen(true)] out PowerRatio? return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is PowerRatioUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerRatioUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(PowerRatioUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index b5b9327c35..0af61a109b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -1480,7 +1480,7 @@ public double As(PressureUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1658,30 +1658,6 @@ private bool TryToUnit(PressureUnit unit, [NotNullWhen(true)] out Pressure? conv return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is PressureUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(PressureUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index 7d88c1ba27..e8c71e268e 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -891,7 +891,7 @@ public double As(PressureChangeRateUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1005,30 +1005,6 @@ private bool TryToUnit(PressureChangeRateUnit unit, [NotNullWhen(true)] out Pres return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is PressureChangeRateUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureChangeRateUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(PressureChangeRateUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs index 398767afa5..56ef60318b 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs @@ -706,7 +706,7 @@ public double As(RadiationEquivalentDoseUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -796,30 +796,6 @@ private bool TryToUnit(RadiationEquivalentDoseUnit unit, [NotNullWhen(true)] out return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not RadiationEquivalentDoseUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RadiationEquivalentDoseUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is RadiationEquivalentDoseUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RadiationEquivalentDoseUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(RadiationEquivalentDoseUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs index 0eba4aa687..49845f4647 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs @@ -763,7 +763,7 @@ public double As(RadiationEquivalentDoseRateUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -861,30 +861,6 @@ private bool TryToUnit(RadiationEquivalentDoseRateUnit unit, [NotNullWhen(true)] return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not RadiationEquivalentDoseRateUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RadiationEquivalentDoseRateUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is RadiationEquivalentDoseRateUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RadiationEquivalentDoseRateUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(RadiationEquivalentDoseRateUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs index 9aa6727d42..1e8e65cc30 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs @@ -720,7 +720,7 @@ public double As(RadiationExposureUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -814,30 +814,6 @@ private bool TryToUnit(RadiationExposureUnit unit, [NotNullWhen(true)] out Radia return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not RadiationExposureUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RadiationExposureUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is RadiationExposureUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RadiationExposureUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(RadiationExposureUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs index 42e52dd299..e5ed1df575 100644 --- a/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs @@ -1056,7 +1056,7 @@ public double As(RadioactivityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1192,30 +1192,6 @@ private bool TryToUnit(RadioactivityUnit unit, [NotNullWhen(true)] out Radioacti return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not RadioactivityUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RadioactivityUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is RadioactivityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RadioactivityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(RadioactivityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index 6e8ac189b7..3791b4a0ac 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -674,7 +674,7 @@ public double As(RatioUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -764,30 +764,6 @@ private bool TryToUnit(RatioUnit unit, [NotNullWhen(true)] out Ratio? converted) return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is RatioUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(RatioUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index 158bb44aa5..84b107fe5a 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -624,7 +624,7 @@ public double As(RatioChangeRateUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -706,30 +706,6 @@ private bool TryToUnit(RatioChangeRateUnit unit, [NotNullWhen(true)] out RatioCh return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is RatioChangeRateUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioChangeRateUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(RatioChangeRateUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index adc4aee4dc..9c6f80d208 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -817,7 +817,7 @@ public double As(ReciprocalAreaUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -917,30 +917,6 @@ private bool TryToUnit(ReciprocalAreaUnit unit, [NotNullWhen(true)] out Reciproc return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ReciprocalAreaUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalAreaUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ReciprocalAreaUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index d364efdece..123049b7aa 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -815,7 +815,7 @@ public double As(ReciprocalLengthUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -913,30 +913,6 @@ private bool TryToUnit(ReciprocalLengthUnit unit, [NotNullWhen(true)] out Recipr return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ReciprocalLengthUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalLengthUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ReciprocalLengthUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index 03a2d50ca6..8268935303 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -594,7 +594,7 @@ public double As(RelativeHumidityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -674,30 +674,6 @@ private bool TryToUnit(RelativeHumidityUnit unit, [NotNullWhen(true)] out Relati return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is RelativeHumidityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RelativeHumidityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(RelativeHumidityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index ad56c66b1c..fc357d5237 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -656,7 +656,7 @@ public double As(RotationalAccelerationUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -742,30 +742,6 @@ private bool TryToUnit(RotationalAccelerationUnit unit, [NotNullWhen(true)] out return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is RotationalAccelerationUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalAccelerationUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(RotationalAccelerationUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index d279f43a9c..14b7c641c1 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -818,7 +818,7 @@ public double As(RotationalSpeedUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -922,30 +922,6 @@ private bool TryToUnit(RotationalSpeedUnit unit, [NotNullWhen(true)] out Rotatio return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is RotationalSpeedUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalSpeedUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(RotationalSpeedUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index 92bd9383db..ad151e3084 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -1161,7 +1161,7 @@ public double As(RotationalStiffnessUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1307,30 +1307,6 @@ private bool TryToUnit(RotationalStiffnessUnit unit, [NotNullWhen(true)] out Rot return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is RotationalStiffnessUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(RotationalStiffnessUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 4d6720838c..a3054dc13a 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -683,7 +683,7 @@ public double As(RotationalStiffnessPerLengthUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -771,30 +771,6 @@ private bool TryToUnit(RotationalStiffnessPerLengthUnit unit, [NotNullWhen(true) return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is RotationalStiffnessPerLengthUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessPerLengthUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(RotationalStiffnessPerLengthUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index 1a6c7090b2..ed7b5896d1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -594,7 +594,7 @@ public double As(ScalarUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -674,30 +674,6 @@ private bool TryToUnit(ScalarUnit unit, [NotNullWhen(true)] out Scalar? converte return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ScalarUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ScalarUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ScalarUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index 03161c972d..9a03bb14ad 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -597,7 +597,7 @@ public double As(SolidAngleUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -677,30 +677,6 @@ private bool TryToUnit(SolidAngleUnit unit, [NotNullWhen(true)] out SolidAngle? return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is SolidAngleUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SolidAngleUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(SolidAngleUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index a8348b11bc..287fa1a9ac 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -1127,7 +1127,7 @@ public double As(SpecificEnergyUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1265,30 +1265,6 @@ private bool TryToUnit(SpecificEnergyUnit unit, [NotNullWhen(true)] out Specific return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is SpecificEnergyUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEnergyUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(SpecificEnergyUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index d2310827fa..1b59aeee2c 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -754,7 +754,7 @@ public double As(SpecificEntropyUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -850,30 +850,6 @@ private bool TryToUnit(SpecificEntropyUnit unit, [NotNullWhen(true)] out Specifi return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is SpecificEntropyUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEntropyUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(SpecificEntropyUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 651c2220c6..922686c007 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -659,7 +659,7 @@ public double As(SpecificFuelConsumptionUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -745,30 +745,6 @@ private bool TryToUnit(SpecificFuelConsumptionUnit unit, [NotNullWhen(true)] out return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is SpecificFuelConsumptionUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(SpecificFuelConsumptionUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index 7ae16866b1..830f864f6f 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -658,7 +658,7 @@ public double As(SpecificVolumeUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -742,30 +742,6 @@ private bool TryToUnit(SpecificVolumeUnit unit, [NotNullWhen(true)] out Specific return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is SpecificVolumeUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificVolumeUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(SpecificVolumeUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index c78cceb1f8..0cded592d3 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -906,7 +906,7 @@ public double As(SpecificWeightUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1018,30 +1018,6 @@ private bool TryToUnit(SpecificWeightUnit unit, [NotNullWhen(true)] out Specific return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is SpecificWeightUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificWeightUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(SpecificWeightUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index a83d583d9f..660277f5bf 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -1180,7 +1180,7 @@ public double As(SpeedUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1324,30 +1324,6 @@ private bool TryToUnit(SpeedUnit unit, [NotNullWhen(true)] out Speed? converted) return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is SpeedUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpeedUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(SpeedUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 71e9291cd5..a876cc128a 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -736,7 +736,7 @@ public double As(StandardVolumeFlowUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -832,30 +832,6 @@ private bool TryToUnit(StandardVolumeFlowUnit unit, [NotNullWhen(true)] out Stan return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is StandardVolumeFlowUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(StandardVolumeFlowUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(StandardVolumeFlowUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index 94e66aff64..3ccb9e7800 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -705,7 +705,7 @@ public double As(TemperatureUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -803,30 +803,6 @@ private bool TryToUnit(TemperatureUnit unit, [NotNullWhen(true)] out Temperature return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is TemperatureUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(TemperatureUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index d58f304272..bc536b196c 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -875,7 +875,7 @@ public double As(TemperatureChangeRateUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -987,30 +987,6 @@ private bool TryToUnit(TemperatureChangeRateUnit unit, [NotNullWhen(true)] out T return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is TemperatureChangeRateUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureChangeRateUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(TemperatureChangeRateUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 8a61a120c5..b15ebc07f7 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -789,7 +789,7 @@ public double As(TemperatureDeltaUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -885,30 +885,6 @@ private bool TryToUnit(TemperatureDeltaUnit unit, [NotNullWhen(true)] out Temper return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is TemperatureDeltaUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureDeltaUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(TemperatureDeltaUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs index 733e4efbd5..4543eece3a 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -667,7 +667,7 @@ public double As(TemperatureGradientUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -753,30 +753,6 @@ private bool TryToUnit(TemperatureGradientUnit unit, [NotNullWhen(true)] out Tem return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is TemperatureGradientUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureGradientUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(TemperatureGradientUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index 5564969048..b8fae6d3d7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -643,7 +643,7 @@ public double As(ThermalConductivityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -727,30 +727,6 @@ private bool TryToUnit(ThermalConductivityUnit unit, [NotNullWhen(true)] out The return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ThermalConductivityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalConductivityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ThermalConductivityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs index a12b5c84e3..1da9b5731f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs @@ -704,7 +704,7 @@ public double As(ThermalInsulanceUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -796,30 +796,6 @@ private bool TryToUnit(ThermalInsulanceUnit unit, [NotNullWhen(true)] out Therma return true; } - #region Explicit implementations - - double IQuantity.As(Enum unit) - { - if (unit is not ThermalInsulanceUnit typedUnit) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalInsulanceUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ThermalInsulanceUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalInsulanceUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ThermalInsulanceUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index 70d4dc4ec3..2fe84bd491 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -624,7 +624,7 @@ public double As(ThermalResistanceUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -706,30 +706,6 @@ private bool TryToUnit(ThermalResistanceUnit unit, [NotNullWhen(true)] out Therm return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is ThermalResistanceUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalResistanceUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(ThermalResistanceUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index b1afb8bb9a..e511e71e8b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -1045,7 +1045,7 @@ public double As(TorqueUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1173,30 +1173,6 @@ private bool TryToUnit(TorqueUnit unit, [NotNullWhen(true)] out Torque? converte return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is TorqueUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorqueUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(TorqueUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index c656b0933b..fde1b75bbe 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -597,7 +597,7 @@ public double As(TurbidityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -677,30 +677,6 @@ private bool TryToUnit(TurbidityUnit unit, [NotNullWhen(true)] out Turbidity? co return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is TurbidityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TurbidityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(TurbidityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index 5428c6d04a..73dc731985 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -594,7 +594,7 @@ public double As(VitaminAUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -674,30 +674,6 @@ private bool TryToUnit(VitaminAUnit unit, [NotNullWhen(true)] out VitaminA? conv return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is VitaminAUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VitaminAUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(VitaminAUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 61ce6a93b4..d261cfcc62 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -1574,7 +1574,7 @@ public double As(VolumeUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1762,30 +1762,6 @@ private bool TryToUnit(VolumeUnit unit, [NotNullWhen(true)] out Volume? converte return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is VolumeUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(VolumeUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 62a506c8b8..8f3db26475 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -919,7 +919,7 @@ public double As(VolumeConcentrationUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -1037,30 +1037,6 @@ private bool TryToUnit(VolumeConcentrationUnit unit, [NotNullWhen(true)] out Vol return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is VolumeConcentrationUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeConcentrationUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(VolumeConcentrationUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index 29b9e3f883..ec34176eba 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -1831,7 +1831,7 @@ public double As(VolumeFlowUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -2059,30 +2059,6 @@ private bool TryToUnit(VolumeFlowUnit unit, [NotNullWhen(true)] out VolumeFlow? return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is VolumeFlowUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(VolumeFlowUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs index 8c68f630f0..59d0b6f990 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs @@ -624,7 +624,7 @@ public double As(VolumeFlowPerAreaUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -706,30 +706,6 @@ private bool TryToUnit(VolumeFlowPerAreaUnit unit, [NotNullWhen(true)] out Volum return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is VolumeFlowPerAreaUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowPerAreaUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(VolumeFlowPerAreaUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index c4c8b65637..2e134bdab8 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -736,7 +736,7 @@ public double As(VolumePerLengthUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -832,30 +832,6 @@ private bool TryToUnit(VolumePerLengthUnit unit, [NotNullWhen(true)] out VolumeP return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is VolumePerLengthUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumePerLengthUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(VolumePerLengthUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 937bcfc4bf..802c1dadaa 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -739,7 +739,7 @@ public double As(VolumetricHeatCapacityUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -835,30 +835,6 @@ private bool TryToUnit(VolumetricHeatCapacityUnit unit, [NotNullWhen(true)] out return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is VolumetricHeatCapacityUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumetricHeatCapacityUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(VolumetricHeatCapacityUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index ea51d4f63f..89a033a478 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -688,7 +688,7 @@ public double As(WarpingMomentOfInertiaUnit unit) return ToUnit(unit).Value; } - /// + /// public double As(UnitKey unitKey) { return As(unitKey.ToUnit()); @@ -778,30 +778,6 @@ private bool TryToUnit(WarpingMomentOfInertiaUnit unit, [NotNullWhen(true)] out return true; } - #region Explicit implementations - - double IQuantity.As(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 As(typedUnit); - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is WarpingMomentOfInertiaUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(WarpingMomentOfInertiaUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - IQuantity IQuantity.ToUnit(WarpingMomentOfInertiaUnit unit) => ToUnit(unit); - - #endregion - #endregion #region ToString Methods diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index 2cc04964fa..3b481e108c 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -20,22 +20,6 @@ public interface IQuantity : IFormattable #endif QuantityInfo QuantityInfo { get; } - /// - /// Gets the value in the given unit. - /// - /// The unit enum value. The unit must be compatible, so for you should provide a value. - /// Value converted to the specified unit. - /// Wrong unit enum type was given. - double As(Enum unit); - - /// - /// Gets the value in the given unit key. - /// - /// The unit key. The unit type must be compatible, so for you should provide a value. - /// Value converted to the specified unit. - /// Wrong unit enum type was given. - double As(UnitKey unitKey); - /// /// The unit this quantity was constructed with -or- BaseUnit if default ctor was used. /// @@ -46,17 +30,6 @@ public interface IQuantity : IFormattable /// double Value { get; } - /// - /// 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 . - IQuantity ToUnit(Enum unit); - /// /// Gets the unique key for the unit type and its corresponding value. /// @@ -79,12 +52,6 @@ public interface IQuantity : IFormattable public interface IQuantity : IQuantity where TUnitType : struct, Enum { - /// - /// Convert to a unit representation . - /// - /// Value converted to the specified unit. - double As(TUnitType unit); - /// new TUnitType Unit { get; } @@ -94,14 +61,6 @@ public interface IQuantity : IQuantity #endif new QuantityInfo QuantityInfo { get; } - /// - /// Converts this to an in the given . - /// - /// The unit value. - /// Conversion was not possible from this to . - /// A new in the given . - IQuantity ToUnit(TUnitType unit); - #if NET #region Implementation of IQuantity @@ -183,16 +142,6 @@ public interface IQuantity : IQuantityOfType, IQuantity /// An instance of the quantity with the specified value and unit. static abstract TSelf From(double value, TUnitType unit); - /// - /// Converts this quantity to the specified unit while preserving its concrete quantity type. - /// - /// The unit value. - /// A new in the specified unit. - new TSelf ToUnit(TUnitType unit) - { - return TSelf.From(As(unit), unit); - } - static TSelf IQuantityOfType.Create(double value, UnitKey unit) => TSelf.From(value, unit.ToUnit()); static QuantityInfo IQuantityOfType.Info => TSelf.Info; @@ -204,10 +153,6 @@ QuantityInfo IQuantity.QuantityInfo } #pragma warning restore CS0618 - IQuantity IQuantity.ToUnit(TUnitType unit) - { - return ToUnit(unit); - } #endif }