From a83c44d9e349cee099c3f3d08ac3013bf0f470dc Mon Sep 17 00:00:00 2001 From: Tristan Milnthorp Date: Wed, 9 Feb 2022 16:28:25 -0500 Subject: [PATCH] Use pattern matching for switch statements (#1038) --- .../NanoFrameworkGen/QuantityGenerator.cs | 18 +- .../UnitsNetGen/StaticQuantityGenerator.cs | 30 +- .../Quantities/Acceleration.g.cs | 70 +- .../Quantities/AmountOfSubstance.g.cs | 74 +- .../Quantities/AmplitudeRatio.g.cs | 30 +- .../GeneratedCode/Quantities/Angle.g.cs | 78 +- .../Quantities/ApparentEnergy.g.cs | 26 +- .../Quantities/ApparentPower.g.cs | 30 +- .../GeneratedCode/Quantities/Area.g.cs | 70 +- .../GeneratedCode/Quantities/AreaDensity.g.cs | 18 +- .../Quantities/AreaMomentOfInertia.g.cs | 38 +- .../GeneratedCode/Quantities/BitRate.g.cs | 118 +- .../BrakeSpecificFuelConsumption.g.cs | 26 +- .../GeneratedCode/Quantities/Capacitance.g.cs | 42 +- .../CoefficientOfThermalExpansion.g.cs | 26 +- .../GeneratedCode/Quantities/Density.g.cs | 218 ++-- .../GeneratedCode/Quantities/Duration.g.cs | 58 +- .../Quantities/DynamicViscosity.g.cs | 54 +- .../Quantities/ElectricAdmittance.g.cs | 30 +- .../Quantities/ElectricCharge.g.cs | 34 +- .../Quantities/ElectricChargeDensity.g.cs | 18 +- .../Quantities/ElectricConductance.g.cs | 26 +- .../Quantities/ElectricConductivity.g.cs | 26 +- .../Quantities/ElectricCurrent.g.cs | 46 +- .../Quantities/ElectricCurrentDensity.g.cs | 26 +- .../Quantities/ElectricCurrentGradient.g.cs | 30 +- .../Quantities/ElectricField.g.cs | 18 +- .../Quantities/ElectricInductance.g.cs | 30 +- .../Quantities/ElectricPotential.g.cs | 34 +- .../Quantities/ElectricPotentialAc.g.cs | 34 +- .../ElectricPotentialChangeRate.g.cs | 94 +- .../Quantities/ElectricPotentialDc.g.cs | 34 +- .../Quantities/ElectricResistance.g.cs | 38 +- .../Quantities/ElectricResistivity.g.cs | 70 +- .../ElectricSurfaceChargeDensity.g.cs | 26 +- .../GeneratedCode/Quantities/Energy.g.cs | 158 ++- .../GeneratedCode/Quantities/Entropy.g.cs | 42 +- .../GeneratedCode/Quantities/Force.g.cs | 74 +- .../Quantities/ForceChangeRate.g.cs | 74 +- .../Quantities/ForcePerLength.g.cs | 166 ++- .../GeneratedCode/Quantities/Frequency.g.cs | 58 +- .../Quantities/FuelEfficiency.g.cs | 30 +- .../GeneratedCode/Quantities/HeatFlux.g.cs | 86 +- .../Quantities/HeatTransferCoefficient.g.cs | 26 +- .../GeneratedCode/Quantities/Illuminance.g.cs | 30 +- .../GeneratedCode/Quantities/Information.g.cs | 118 +- .../GeneratedCode/Quantities/Irradiance.g.cs | 70 +- .../GeneratedCode/Quantities/Irradiation.g.cs | 42 +- .../Quantities/KinematicViscosity.g.cs | 50 +- .../GeneratedCode/Quantities/LapseRate.g.cs | 18 +- .../GeneratedCode/Quantities/Length.g.cs | 150 ++- .../GeneratedCode/Quantities/Level.g.cs | 22 +- .../Quantities/LinearDensity.g.cs | 70 +- .../Quantities/LinearPowerDensity.g.cs | 114 +- .../GeneratedCode/Quantities/Luminosity.g.cs | 70 +- .../Quantities/LuminousFlux.g.cs | 18 +- .../Quantities/LuminousIntensity.g.cs | 18 +- .../Quantities/MagneticField.g.cs | 38 +- .../Quantities/MagneticFlux.g.cs | 18 +- .../Quantities/Magnetization.g.cs | 18 +- .../GeneratedCode/Quantities/Mass.g.cs | 114 +- .../Quantities/MassConcentration.g.cs | 210 ++-- .../GeneratedCode/Quantities/MassFlow.g.cs | 146 ++- .../GeneratedCode/Quantities/MassFlux.g.cs | 62 +- .../Quantities/MassFraction.g.cs | 110 +- .../Quantities/MassMomentOfInertia.g.cs | 126 +- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 26 +- .../Quantities/MolarEntropy.g.cs | 26 +- .../GeneratedCode/Quantities/MolarMass.g.cs | 62 +- .../GeneratedCode/Quantities/Molarity.g.cs | 78 +- .../Quantities/Permeability.g.cs | 18 +- .../Quantities/Permittivity.g.cs | 18 +- .../GeneratedCode/Quantities/Power.g.cs | 114 +- .../Quantities/PowerDensity.g.cs | 190 ++- .../GeneratedCode/Quantities/PowerRatio.g.cs | 22 +- .../GeneratedCode/Quantities/Pressure.g.cs | 194 ++-- .../Quantities/PressureChangeRate.g.cs | 70 +- .../GeneratedCode/Quantities/Ratio.g.cs | 38 +- .../Quantities/RatioChangeRate.g.cs | 22 +- .../Quantities/ReactiveEnergy.g.cs | 26 +- .../Quantities/ReactivePower.g.cs | 30 +- .../Quantities/ReciprocalArea.g.cs | 58 +- .../Quantities/ReciprocalLength.g.cs | 54 +- .../Quantities/RelativeHumidity.g.cs | 18 +- .../Quantities/RotationalAcceleration.g.cs | 30 +- .../Quantities/RotationalSpeed.g.cs | 66 +- .../Quantities/RotationalStiffness.g.cs | 146 ++- .../RotationalStiffnessPerLength.g.cs | 34 +- .../GeneratedCode/Quantities/Scalar.g.cs | 18 +- .../GeneratedCode/Quantities/SolidAngle.g.cs | 18 +- .../Quantities/SpecificEnergy.g.cs | 114 +- .../Quantities/SpecificEntropy.g.cs | 50 +- .../Quantities/SpecificFuelConsumption.g.cs | 30 +- .../Quantities/SpecificVolume.g.cs | 26 +- .../Quantities/SpecificWeight.g.cs | 82 +- .../GeneratedCode/Quantities/Speed.g.cs | 142 ++- .../Quantities/StandardVolumeFlow.g.cs | 50 +- .../GeneratedCode/Quantities/Temperature.g.cs | 54 +- .../Quantities/TemperatureChangeRate.g.cs | 54 +- .../Quantities/TemperatureDelta.g.cs | 50 +- .../Quantities/TemperatureGradient.g.cs | 30 +- .../Quantities/ThermalConductivity.g.cs | 22 +- .../Quantities/ThermalResistance.g.cs | 38 +- .../GeneratedCode/Quantities/Torque.g.cs | 114 +- .../Quantities/TorquePerLength.g.cs | 98 +- .../GeneratedCode/Quantities/Turbidity.g.cs | 18 +- .../GeneratedCode/Quantities/VitaminA.g.cs | 18 +- .../GeneratedCode/Quantities/Volume.g.cs | 222 ++-- .../Quantities/VolumeConcentration.g.cs | 94 +- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 262 +++-- .../Quantities/VolumeFlowPerArea.g.cs | 22 +- .../Quantities/VolumePerLength.g.cs | 42 +- .../Quantities/VolumetricHeatCapacity.g.cs | 50 +- .../Quantities/WarpingMomentOfInertia.g.cs | 38 +- UnitsNet.Tests/QuantityTest.cs | 1 + UnitsNet/GeneratedCode/Quantity.g.cs | 1029 ++++++----------- 116 files changed, 3770 insertions(+), 4340 deletions(-) diff --git a/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs index 2b682af0bf..fc8436d88a 100644 --- a/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs @@ -208,19 +208,18 @@ private void GenerateConversionMethods() /// The value in the base unit representation. private {_quantity.BaseType} GetValueInBaseUnit() {{ - switch(Unit) + return Unit switch {{"); foreach (var unit in _quantity.Units) { var func = unit.FromUnitToBaseFunc.Replace("{x}", "_value"); Writer.WL($@" - case {_unitEnumName}.{unit.SingularName}: return {func};"); + {_unitEnumName}.{unit.SingularName} => {func},"); } Writer.WL($@" - default: - throw new NotImplementedException($""Can not convert {{Unit}} to base units.""); - }} + _ => throw new NotImplementedException($""Can not convert {{Unit}} to base units."") + }}; }} private {_quantity.BaseType} GetValueAs({_unitEnumName} unit) @@ -230,19 +229,18 @@ private void GenerateConversionMethods() var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch {{"); foreach (var unit in _quantity.Units) { var func = unit.FromBaseToUnitFunc.Replace("{x}", "baseUnitValue"); Writer.WL($@" - case {_unitEnumName}.{unit.SingularName}: return {func};"); + {_unitEnumName}.{unit.SingularName} => {func},"); } Writer.WL(@" - default: - throw new NotImplementedException($""Can not convert {Unit} to {unit}.""); - } + _ => throw new NotImplementedException($""Can not convert {Unit} to {unit}."") + }; } #endregion diff --git a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs index f85c8e43e2..383c895dff 100644 --- a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs @@ -52,20 +52,18 @@ public static partial class Quantity [Obsolete(""QuantityType will be removed. Use FromQuantityInfo(QuantityInfo, QuantityValue) instead."")] public static IQuantity FromQuantityType(QuantityType quantityType, QuantityValue value) { - switch(quantityType) + return quantityType switch {"); foreach (var quantity in _quantities) { var quantityName = quantity.Name; Writer.WL($@" - case QuantityType.{quantityName}: - return {quantityName}.From(value, {quantityName}.BaseUnit);"); + QuantityType.{quantityName} => {quantityName}.From(value, {quantityName}.BaseUnit),"); } Writer.WL(@" - default: - throw new ArgumentException($""{quantityType} is not a supported quantity type.""); - } + _ => throw new ArgumentException($""{quantityType} is not a supported quantity type."") + }; } /// @@ -76,20 +74,18 @@ public static IQuantity FromQuantityType(QuantityType quantityType, QuantityValu /// The created quantity. public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, QuantityValue value) { - switch(quantityInfo.Name) + return quantityInfo.Name switch {"); foreach (var quantity in _quantities) { var quantityName = quantity.Name; Writer.WL($@" - case ""{quantityName}"": - return {quantityName}.From(value, {quantityName}.BaseUnit);"); + ""{quantityName}"" => {quantityName}.From(value, {quantityName}.BaseUnit),"); } Writer.WL(@" - default: - throw new ArgumentException($""{quantityInfo.Name} is not a supported quantity.""); - } + _ => throw new ArgumentException($""{quantityInfo.Name} is not a supported quantity."") + }; } /// @@ -140,20 +136,18 @@ public static bool TryParse(IFormatProvider? formatProvider, Type quantityType, var parser = QuantityParser.Default; - switch(quantityType) + return quantityType switch {"); foreach (var quantity in _quantities) { var quantityName = quantity.Name; Writer.WL($@" - case Type _ when quantityType == typeof({quantityName}): - return parser.TryParse<{quantityName}, {quantityName}Unit>(quantityString, formatProvider, {quantityName}.From, out quantity);"); + Type _ when quantityType == typeof({quantityName}) => parser.TryParse<{quantityName}, {quantityName}Unit>(quantityString, formatProvider, {quantityName}.From, out quantity),"); } Writer.WL(@" - default: - return false; - } + _ => false + }; } internal static IEnumerable GetQuantityTypes() diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Acceleration.g.cs index 874c2ec9c9..b9f5e5cbd3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Acceleration.g.cs @@ -274,25 +274,24 @@ public Acceleration ToUnit(AccelerationUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case AccelerationUnit.CentimeterPerSecondSquared: return (_value) * 1e-2d; - case AccelerationUnit.DecimeterPerSecondSquared: return (_value) * 1e-1d; - case AccelerationUnit.FootPerSecondSquared: return _value*0.304800; - case AccelerationUnit.InchPerSecondSquared: return _value*0.0254; - case AccelerationUnit.KilometerPerSecondSquared: return (_value) * 1e3d; - case AccelerationUnit.KnotPerHour: return _value*0.5144444444444/3600; - case AccelerationUnit.KnotPerMinute: return _value*0.5144444444444/60; - case AccelerationUnit.KnotPerSecond: return _value*0.5144444444444; - case AccelerationUnit.MeterPerSecondSquared: return _value; - case AccelerationUnit.MicrometerPerSecondSquared: return (_value) * 1e-6d; - case AccelerationUnit.MillimeterPerSecondSquared: return (_value) * 1e-3d; - case AccelerationUnit.MillistandardGravity: return (_value*9.80665) * 1e-3d; - case AccelerationUnit.NanometerPerSecondSquared: return (_value) * 1e-9d; - case AccelerationUnit.StandardGravity: return _value*9.80665; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + AccelerationUnit.CentimeterPerSecondSquared => (_value) * 1e-2d, + AccelerationUnit.DecimeterPerSecondSquared => (_value) * 1e-1d, + AccelerationUnit.FootPerSecondSquared => _value*0.304800, + AccelerationUnit.InchPerSecondSquared => _value*0.0254, + AccelerationUnit.KilometerPerSecondSquared => (_value) * 1e3d, + AccelerationUnit.KnotPerHour => _value*0.5144444444444/3600, + AccelerationUnit.KnotPerMinute => _value*0.5144444444444/60, + AccelerationUnit.KnotPerSecond => _value*0.5144444444444, + AccelerationUnit.MeterPerSecondSquared => _value, + AccelerationUnit.MicrometerPerSecondSquared => (_value) * 1e-6d, + AccelerationUnit.MillimeterPerSecondSquared => (_value) * 1e-3d, + AccelerationUnit.MillistandardGravity => (_value*9.80665) * 1e-3d, + AccelerationUnit.NanometerPerSecondSquared => (_value) * 1e-9d, + AccelerationUnit.StandardGravity => _value*9.80665, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(AccelerationUnit unit) @@ -302,25 +301,24 @@ private double GetValueAs(AccelerationUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case AccelerationUnit.CentimeterPerSecondSquared: return (baseUnitValue) / 1e-2d; - case AccelerationUnit.DecimeterPerSecondSquared: return (baseUnitValue) / 1e-1d; - case AccelerationUnit.FootPerSecondSquared: return baseUnitValue/0.304800; - case AccelerationUnit.InchPerSecondSquared: return baseUnitValue/0.0254; - case AccelerationUnit.KilometerPerSecondSquared: return (baseUnitValue) / 1e3d; - case AccelerationUnit.KnotPerHour: return baseUnitValue/0.5144444444444*3600; - case AccelerationUnit.KnotPerMinute: return baseUnitValue/0.5144444444444*60; - case AccelerationUnit.KnotPerSecond: return baseUnitValue/0.5144444444444; - case AccelerationUnit.MeterPerSecondSquared: return baseUnitValue; - case AccelerationUnit.MicrometerPerSecondSquared: return (baseUnitValue) / 1e-6d; - case AccelerationUnit.MillimeterPerSecondSquared: return (baseUnitValue) / 1e-3d; - case AccelerationUnit.MillistandardGravity: return (baseUnitValue/9.80665) / 1e-3d; - case AccelerationUnit.NanometerPerSecondSquared: return (baseUnitValue) / 1e-9d; - case AccelerationUnit.StandardGravity: return baseUnitValue/9.80665; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + AccelerationUnit.CentimeterPerSecondSquared => (baseUnitValue) / 1e-2d, + AccelerationUnit.DecimeterPerSecondSquared => (baseUnitValue) / 1e-1d, + AccelerationUnit.FootPerSecondSquared => baseUnitValue/0.304800, + AccelerationUnit.InchPerSecondSquared => baseUnitValue/0.0254, + AccelerationUnit.KilometerPerSecondSquared => (baseUnitValue) / 1e3d, + AccelerationUnit.KnotPerHour => baseUnitValue/0.5144444444444*3600, + AccelerationUnit.KnotPerMinute => baseUnitValue/0.5144444444444*60, + AccelerationUnit.KnotPerSecond => baseUnitValue/0.5144444444444, + AccelerationUnit.MeterPerSecondSquared => baseUnitValue, + AccelerationUnit.MicrometerPerSecondSquared => (baseUnitValue) / 1e-6d, + AccelerationUnit.MillimeterPerSecondSquared => (baseUnitValue) / 1e-3d, + AccelerationUnit.MillistandardGravity => (baseUnitValue/9.80665) / 1e-3d, + AccelerationUnit.NanometerPerSecondSquared => (baseUnitValue) / 1e-9d, + AccelerationUnit.StandardGravity => baseUnitValue/9.80665, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 4fd741b4d0..9a70fa0118 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -285,26 +285,25 @@ public AmountOfSubstance ToUnit(AmountOfSubstanceUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case AmountOfSubstanceUnit.Centimole: return (_value) * 1e-2d; - case AmountOfSubstanceUnit.CentipoundMole: return (_value*453.59237) * 1e-2d; - case AmountOfSubstanceUnit.Decimole: return (_value) * 1e-1d; - case AmountOfSubstanceUnit.DecipoundMole: return (_value*453.59237) * 1e-1d; - case AmountOfSubstanceUnit.Kilomole: return (_value) * 1e3d; - case AmountOfSubstanceUnit.KilopoundMole: return (_value*453.59237) * 1e3d; - case AmountOfSubstanceUnit.Megamole: return (_value) * 1e6d; - case AmountOfSubstanceUnit.Micromole: return (_value) * 1e-6d; - case AmountOfSubstanceUnit.MicropoundMole: return (_value*453.59237) * 1e-6d; - case AmountOfSubstanceUnit.Millimole: return (_value) * 1e-3d; - case AmountOfSubstanceUnit.MillipoundMole: return (_value*453.59237) * 1e-3d; - case AmountOfSubstanceUnit.Mole: return _value; - case AmountOfSubstanceUnit.Nanomole: return (_value) * 1e-9d; - case AmountOfSubstanceUnit.NanopoundMole: return (_value*453.59237) * 1e-9d; - case AmountOfSubstanceUnit.PoundMole: return _value*453.59237; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + AmountOfSubstanceUnit.Centimole => (_value) * 1e-2d, + AmountOfSubstanceUnit.CentipoundMole => (_value*453.59237) * 1e-2d, + AmountOfSubstanceUnit.Decimole => (_value) * 1e-1d, + AmountOfSubstanceUnit.DecipoundMole => (_value*453.59237) * 1e-1d, + AmountOfSubstanceUnit.Kilomole => (_value) * 1e3d, + AmountOfSubstanceUnit.KilopoundMole => (_value*453.59237) * 1e3d, + AmountOfSubstanceUnit.Megamole => (_value) * 1e6d, + AmountOfSubstanceUnit.Micromole => (_value) * 1e-6d, + AmountOfSubstanceUnit.MicropoundMole => (_value*453.59237) * 1e-6d, + AmountOfSubstanceUnit.Millimole => (_value) * 1e-3d, + AmountOfSubstanceUnit.MillipoundMole => (_value*453.59237) * 1e-3d, + AmountOfSubstanceUnit.Mole => _value, + AmountOfSubstanceUnit.Nanomole => (_value) * 1e-9d, + AmountOfSubstanceUnit.NanopoundMole => (_value*453.59237) * 1e-9d, + AmountOfSubstanceUnit.PoundMole => _value*453.59237, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(AmountOfSubstanceUnit unit) @@ -314,26 +313,25 @@ private double GetValueAs(AmountOfSubstanceUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case AmountOfSubstanceUnit.Centimole: return (baseUnitValue) / 1e-2d; - case AmountOfSubstanceUnit.CentipoundMole: return (baseUnitValue/453.59237) / 1e-2d; - case AmountOfSubstanceUnit.Decimole: return (baseUnitValue) / 1e-1d; - case AmountOfSubstanceUnit.DecipoundMole: return (baseUnitValue/453.59237) / 1e-1d; - case AmountOfSubstanceUnit.Kilomole: return (baseUnitValue) / 1e3d; - case AmountOfSubstanceUnit.KilopoundMole: return (baseUnitValue/453.59237) / 1e3d; - case AmountOfSubstanceUnit.Megamole: return (baseUnitValue) / 1e6d; - case AmountOfSubstanceUnit.Micromole: return (baseUnitValue) / 1e-6d; - case AmountOfSubstanceUnit.MicropoundMole: return (baseUnitValue/453.59237) / 1e-6d; - case AmountOfSubstanceUnit.Millimole: return (baseUnitValue) / 1e-3d; - case AmountOfSubstanceUnit.MillipoundMole: return (baseUnitValue/453.59237) / 1e-3d; - case AmountOfSubstanceUnit.Mole: return baseUnitValue; - case AmountOfSubstanceUnit.Nanomole: return (baseUnitValue) / 1e-9d; - case AmountOfSubstanceUnit.NanopoundMole: return (baseUnitValue/453.59237) / 1e-9d; - case AmountOfSubstanceUnit.PoundMole: return baseUnitValue/453.59237; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + AmountOfSubstanceUnit.Centimole => (baseUnitValue) / 1e-2d, + AmountOfSubstanceUnit.CentipoundMole => (baseUnitValue/453.59237) / 1e-2d, + AmountOfSubstanceUnit.Decimole => (baseUnitValue) / 1e-1d, + AmountOfSubstanceUnit.DecipoundMole => (baseUnitValue/453.59237) / 1e-1d, + AmountOfSubstanceUnit.Kilomole => (baseUnitValue) / 1e3d, + AmountOfSubstanceUnit.KilopoundMole => (baseUnitValue/453.59237) / 1e3d, + AmountOfSubstanceUnit.Megamole => (baseUnitValue) / 1e6d, + AmountOfSubstanceUnit.Micromole => (baseUnitValue) / 1e-6d, + AmountOfSubstanceUnit.MicropoundMole => (baseUnitValue/453.59237) / 1e-6d, + AmountOfSubstanceUnit.Millimole => (baseUnitValue) / 1e-3d, + AmountOfSubstanceUnit.MillipoundMole => (baseUnitValue/453.59237) / 1e-3d, + AmountOfSubstanceUnit.Mole => baseUnitValue, + AmountOfSubstanceUnit.Nanomole => (baseUnitValue) / 1e-9d, + AmountOfSubstanceUnit.NanopoundMole => (baseUnitValue/453.59237) / 1e-9d, + AmountOfSubstanceUnit.PoundMole => baseUnitValue/453.59237, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmplitudeRatio.g.cs index 970033f09d..6a0f8b6b2b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -164,15 +164,14 @@ public AmplitudeRatio ToUnit(AmplitudeRatioUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case AmplitudeRatioUnit.DecibelMicrovolt: return _value - 120; - case AmplitudeRatioUnit.DecibelMillivolt: return _value - 60; - case AmplitudeRatioUnit.DecibelUnloaded: return _value - 2.218487499; - case AmplitudeRatioUnit.DecibelVolt: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + AmplitudeRatioUnit.DecibelMicrovolt => _value - 120, + AmplitudeRatioUnit.DecibelMillivolt => _value - 60, + AmplitudeRatioUnit.DecibelUnloaded => _value - 2.218487499, + AmplitudeRatioUnit.DecibelVolt => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(AmplitudeRatioUnit unit) @@ -182,15 +181,14 @@ private double GetValueAs(AmplitudeRatioUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case AmplitudeRatioUnit.DecibelMicrovolt: return baseUnitValue + 120; - case AmplitudeRatioUnit.DecibelMillivolt: return baseUnitValue + 60; - case AmplitudeRatioUnit.DecibelUnloaded: return baseUnitValue + 2.218487499; - case AmplitudeRatioUnit.DecibelVolt: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + AmplitudeRatioUnit.DecibelMicrovolt => baseUnitValue + 120, + AmplitudeRatioUnit.DecibelMillivolt => baseUnitValue + 60, + AmplitudeRatioUnit.DecibelUnloaded => baseUnitValue + 2.218487499, + AmplitudeRatioUnit.DecibelVolt => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs index 768f49c779..e839a84d4b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs @@ -296,27 +296,26 @@ public Angle ToUnit(AngleUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case AngleUnit.Arcminute: return _value/60; - case AngleUnit.Arcsecond: return _value/3600; - case AngleUnit.Centiradian: return (_value*180/3.1415926535897931) * 1e-2d; - case AngleUnit.Deciradian: return (_value*180/3.1415926535897931) * 1e-1d; - case AngleUnit.Degree: return _value; - case AngleUnit.Gradian: return _value*0.9; - case AngleUnit.Microdegree: return (_value) * 1e-6d; - case AngleUnit.Microradian: return (_value*180/3.1415926535897931) * 1e-6d; - case AngleUnit.Millidegree: return (_value) * 1e-3d; - case AngleUnit.Milliradian: return (_value*180/3.1415926535897931) * 1e-3d; - case AngleUnit.Nanodegree: return (_value) * 1e-9d; - case AngleUnit.Nanoradian: return (_value*180/3.1415926535897931) * 1e-9d; - case AngleUnit.NatoMil: return _value*9/160; - case AngleUnit.Radian: return _value*180/3.1415926535897931; - case AngleUnit.Revolution: return _value*360; - case AngleUnit.Tilt: return Math.Asin(_value)*180/3.1415926535897931; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + AngleUnit.Arcminute => _value/60, + AngleUnit.Arcsecond => _value/3600, + AngleUnit.Centiradian => (_value*180/3.1415926535897931) * 1e-2d, + AngleUnit.Deciradian => (_value*180/3.1415926535897931) * 1e-1d, + AngleUnit.Degree => _value, + AngleUnit.Gradian => _value*0.9, + AngleUnit.Microdegree => (_value) * 1e-6d, + AngleUnit.Microradian => (_value*180/3.1415926535897931) * 1e-6d, + AngleUnit.Millidegree => (_value) * 1e-3d, + AngleUnit.Milliradian => (_value*180/3.1415926535897931) * 1e-3d, + AngleUnit.Nanodegree => (_value) * 1e-9d, + AngleUnit.Nanoradian => (_value*180/3.1415926535897931) * 1e-9d, + AngleUnit.NatoMil => _value*9/160, + AngleUnit.Radian => _value*180/3.1415926535897931, + AngleUnit.Revolution => _value*360, + AngleUnit.Tilt => Math.Asin(_value)*180/3.1415926535897931, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(AngleUnit unit) @@ -326,27 +325,26 @@ private double GetValueAs(AngleUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case AngleUnit.Arcminute: return baseUnitValue*60; - case AngleUnit.Arcsecond: return baseUnitValue*3600; - case AngleUnit.Centiradian: return (baseUnitValue/180*3.1415926535897931) / 1e-2d; - case AngleUnit.Deciradian: return (baseUnitValue/180*3.1415926535897931) / 1e-1d; - case AngleUnit.Degree: return baseUnitValue; - case AngleUnit.Gradian: return baseUnitValue/0.9; - case AngleUnit.Microdegree: return (baseUnitValue) / 1e-6d; - case AngleUnit.Microradian: return (baseUnitValue/180*3.1415926535897931) / 1e-6d; - case AngleUnit.Millidegree: return (baseUnitValue) / 1e-3d; - case AngleUnit.Milliradian: return (baseUnitValue/180*3.1415926535897931) / 1e-3d; - case AngleUnit.Nanodegree: return (baseUnitValue) / 1e-9d; - case AngleUnit.Nanoradian: return (baseUnitValue/180*3.1415926535897931) / 1e-9d; - case AngleUnit.NatoMil: return baseUnitValue*160/9; - case AngleUnit.Radian: return baseUnitValue/180*3.1415926535897931; - case AngleUnit.Revolution: return baseUnitValue/360; - case AngleUnit.Tilt: return Math.Sin(baseUnitValue/180*3.1415926535897931); - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + AngleUnit.Arcminute => baseUnitValue*60, + AngleUnit.Arcsecond => baseUnitValue*3600, + AngleUnit.Centiradian => (baseUnitValue/180*3.1415926535897931) / 1e-2d, + AngleUnit.Deciradian => (baseUnitValue/180*3.1415926535897931) / 1e-1d, + AngleUnit.Degree => baseUnitValue, + AngleUnit.Gradian => baseUnitValue/0.9, + AngleUnit.Microdegree => (baseUnitValue) / 1e-6d, + AngleUnit.Microradian => (baseUnitValue/180*3.1415926535897931) / 1e-6d, + AngleUnit.Millidegree => (baseUnitValue) / 1e-3d, + AngleUnit.Milliradian => (baseUnitValue/180*3.1415926535897931) / 1e-3d, + AngleUnit.Nanodegree => (baseUnitValue) / 1e-9d, + AngleUnit.Nanoradian => (baseUnitValue/180*3.1415926535897931) / 1e-9d, + AngleUnit.NatoMil => baseUnitValue*160/9, + AngleUnit.Radian => baseUnitValue/180*3.1415926535897931, + AngleUnit.Revolution => baseUnitValue/360, + AngleUnit.Tilt => Math.Sin(baseUnitValue/180*3.1415926535897931), + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentEnergy.g.cs index a1e0734491..b9f6e71718 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -153,14 +153,13 @@ public ApparentEnergy ToUnit(ApparentEnergyUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ApparentEnergyUnit.KilovoltampereHour: return (_value) * 1e3d; - case ApparentEnergyUnit.MegavoltampereHour: return (_value) * 1e6d; - case ApparentEnergyUnit.VoltampereHour: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ApparentEnergyUnit.KilovoltampereHour => (_value) * 1e3d, + ApparentEnergyUnit.MegavoltampereHour => (_value) * 1e6d, + ApparentEnergyUnit.VoltampereHour => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ApparentEnergyUnit unit) @@ -170,14 +169,13 @@ private double GetValueAs(ApparentEnergyUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ApparentEnergyUnit.KilovoltampereHour: return (baseUnitValue) / 1e3d; - case ApparentEnergyUnit.MegavoltampereHour: return (baseUnitValue) / 1e6d; - case ApparentEnergyUnit.VoltampereHour: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ApparentEnergyUnit.KilovoltampereHour => (baseUnitValue) / 1e3d, + ApparentEnergyUnit.MegavoltampereHour => (baseUnitValue) / 1e6d, + ApparentEnergyUnit.VoltampereHour => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentPower.g.cs index 0c989a55ed..3bf5f16770 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentPower.g.cs @@ -164,15 +164,14 @@ public ApparentPower ToUnit(ApparentPowerUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ApparentPowerUnit.Gigavoltampere: return (_value) * 1e9d; - case ApparentPowerUnit.Kilovoltampere: return (_value) * 1e3d; - case ApparentPowerUnit.Megavoltampere: return (_value) * 1e6d; - case ApparentPowerUnit.Voltampere: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ApparentPowerUnit.Gigavoltampere => (_value) * 1e9d, + ApparentPowerUnit.Kilovoltampere => (_value) * 1e3d, + ApparentPowerUnit.Megavoltampere => (_value) * 1e6d, + ApparentPowerUnit.Voltampere => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ApparentPowerUnit unit) @@ -182,15 +181,14 @@ private double GetValueAs(ApparentPowerUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ApparentPowerUnit.Gigavoltampere: return (baseUnitValue) / 1e9d; - case ApparentPowerUnit.Kilovoltampere: return (baseUnitValue) / 1e3d; - case ApparentPowerUnit.Megavoltampere: return (baseUnitValue) / 1e6d; - case ApparentPowerUnit.Voltampere: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ApparentPowerUnit.Gigavoltampere => (baseUnitValue) / 1e9d, + ApparentPowerUnit.Kilovoltampere => (baseUnitValue) / 1e3d, + ApparentPowerUnit.Megavoltampere => (baseUnitValue) / 1e6d, + ApparentPowerUnit.Voltampere => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Area.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Area.g.cs index 6ac3766aac..768f942e88 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Area.g.cs @@ -274,25 +274,24 @@ public Area ToUnit(AreaUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case AreaUnit.Acre: return _value*4046.85642; - case AreaUnit.Hectare: return _value*1e4; - case AreaUnit.SquareCentimeter: return _value*1e-4; - case AreaUnit.SquareDecimeter: return _value*1e-2; - case AreaUnit.SquareFoot: return _value * 9.290304e-2; - case AreaUnit.SquareInch: return _value*0.00064516; - case AreaUnit.SquareKilometer: return _value*1e6; - case AreaUnit.SquareMeter: return _value; - case AreaUnit.SquareMicrometer: return _value*1e-12; - case AreaUnit.SquareMile: return _value*2.59e6; - case AreaUnit.SquareMillimeter: return _value*1e-6; - case AreaUnit.SquareNauticalMile: return _value*3429904; - case AreaUnit.SquareYard: return _value*0.836127; - case AreaUnit.UsSurveySquareFoot: return _value*0.09290341161; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + AreaUnit.Acre => _value*4046.85642, + AreaUnit.Hectare => _value*1e4, + AreaUnit.SquareCentimeter => _value*1e-4, + AreaUnit.SquareDecimeter => _value*1e-2, + AreaUnit.SquareFoot => _value * 9.290304e-2, + AreaUnit.SquareInch => _value*0.00064516, + AreaUnit.SquareKilometer => _value*1e6, + AreaUnit.SquareMeter => _value, + AreaUnit.SquareMicrometer => _value*1e-12, + AreaUnit.SquareMile => _value*2.59e6, + AreaUnit.SquareMillimeter => _value*1e-6, + AreaUnit.SquareNauticalMile => _value*3429904, + AreaUnit.SquareYard => _value*0.836127, + AreaUnit.UsSurveySquareFoot => _value*0.09290341161, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(AreaUnit unit) @@ -302,25 +301,24 @@ private double GetValueAs(AreaUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case AreaUnit.Acre: return baseUnitValue/4046.85642; - case AreaUnit.Hectare: return baseUnitValue/1e4; - case AreaUnit.SquareCentimeter: return baseUnitValue/1e-4; - case AreaUnit.SquareDecimeter: return baseUnitValue/1e-2; - case AreaUnit.SquareFoot: return baseUnitValue / 9.290304e-2; - case AreaUnit.SquareInch: return baseUnitValue/0.00064516; - case AreaUnit.SquareKilometer: return baseUnitValue/1e6; - case AreaUnit.SquareMeter: return baseUnitValue; - case AreaUnit.SquareMicrometer: return baseUnitValue/1e-12; - case AreaUnit.SquareMile: return baseUnitValue/2.59e6; - case AreaUnit.SquareMillimeter: return baseUnitValue/1e-6; - case AreaUnit.SquareNauticalMile: return baseUnitValue/3429904; - case AreaUnit.SquareYard: return baseUnitValue/0.836127; - case AreaUnit.UsSurveySquareFoot: return baseUnitValue/0.09290341161; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + AreaUnit.Acre => baseUnitValue/4046.85642, + AreaUnit.Hectare => baseUnitValue/1e4, + AreaUnit.SquareCentimeter => baseUnitValue/1e-4, + AreaUnit.SquareDecimeter => baseUnitValue/1e-2, + AreaUnit.SquareFoot => baseUnitValue / 9.290304e-2, + AreaUnit.SquareInch => baseUnitValue/0.00064516, + AreaUnit.SquareKilometer => baseUnitValue/1e6, + AreaUnit.SquareMeter => baseUnitValue, + AreaUnit.SquareMicrometer => baseUnitValue/1e-12, + AreaUnit.SquareMile => baseUnitValue/2.59e6, + AreaUnit.SquareMillimeter => baseUnitValue/1e-6, + AreaUnit.SquareNauticalMile => baseUnitValue/3429904, + AreaUnit.SquareYard => baseUnitValue/0.836127, + AreaUnit.UsSurveySquareFoot => baseUnitValue/0.09290341161, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs index 023d1ba7c0..436005c3c1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs @@ -131,12 +131,11 @@ public AreaDensity ToUnit(AreaDensityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case AreaDensityUnit.KilogramPerSquareMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + AreaDensityUnit.KilogramPerSquareMeter => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(AreaDensityUnit unit) @@ -146,12 +145,11 @@ private double GetValueAs(AreaDensityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case AreaDensityUnit.KilogramPerSquareMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + AreaDensityUnit.KilogramPerSquareMeter => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index cd5e97f2df..e9846e756a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -186,17 +186,16 @@ public AreaMomentOfInertia ToUnit(AreaMomentOfInertiaUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case AreaMomentOfInertiaUnit.CentimeterToTheFourth: return _value/1e8; - case AreaMomentOfInertiaUnit.DecimeterToTheFourth: return _value/1e4; - case AreaMomentOfInertiaUnit.FootToTheFourth: return _value*0.0086309748412416; - case AreaMomentOfInertiaUnit.InchToTheFourth: return _value*0.0000004162314256; - case AreaMomentOfInertiaUnit.MeterToTheFourth: return _value; - case AreaMomentOfInertiaUnit.MillimeterToTheFourth: return _value/1e12; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + AreaMomentOfInertiaUnit.CentimeterToTheFourth => _value/1e8, + AreaMomentOfInertiaUnit.DecimeterToTheFourth => _value/1e4, + AreaMomentOfInertiaUnit.FootToTheFourth => _value*0.0086309748412416, + AreaMomentOfInertiaUnit.InchToTheFourth => _value*0.0000004162314256, + AreaMomentOfInertiaUnit.MeterToTheFourth => _value, + AreaMomentOfInertiaUnit.MillimeterToTheFourth => _value/1e12, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(AreaMomentOfInertiaUnit unit) @@ -206,17 +205,16 @@ private double GetValueAs(AreaMomentOfInertiaUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case AreaMomentOfInertiaUnit.CentimeterToTheFourth: return baseUnitValue*1e8; - case AreaMomentOfInertiaUnit.DecimeterToTheFourth: return baseUnitValue*1e4; - case AreaMomentOfInertiaUnit.FootToTheFourth: return baseUnitValue/0.0086309748412416; - case AreaMomentOfInertiaUnit.InchToTheFourth: return baseUnitValue/0.0000004162314256; - case AreaMomentOfInertiaUnit.MeterToTheFourth: return baseUnitValue; - case AreaMomentOfInertiaUnit.MillimeterToTheFourth: return baseUnitValue*1e12; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + AreaMomentOfInertiaUnit.CentimeterToTheFourth => baseUnitValue*1e8, + AreaMomentOfInertiaUnit.DecimeterToTheFourth => baseUnitValue*1e4, + AreaMomentOfInertiaUnit.FootToTheFourth => baseUnitValue/0.0086309748412416, + AreaMomentOfInertiaUnit.InchToTheFourth => baseUnitValue/0.0000004162314256, + AreaMomentOfInertiaUnit.MeterToTheFourth => baseUnitValue, + AreaMomentOfInertiaUnit.MillimeterToTheFourth => baseUnitValue*1e12, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs index 124bbe5ffb..39989385c9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs @@ -409,37 +409,36 @@ public BitRate ToUnit(BitRateUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case BitRateUnit.BitPerSecond: return _value; - case BitRateUnit.BytePerSecond: return _value*8d; - case BitRateUnit.ExabitPerSecond: return (_value) * 1e18d; - case BitRateUnit.ExabytePerSecond: return (_value*8d) * 1e18d; - case BitRateUnit.ExbibitPerSecond: return (_value) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.ExbibytePerSecond: return (_value*8d) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.GibibitPerSecond: return (_value) * (1024d * 1024 * 1024); - case BitRateUnit.GibibytePerSecond: return (_value*8d) * (1024d * 1024 * 1024); - case BitRateUnit.GigabitPerSecond: return (_value) * 1e9d; - case BitRateUnit.GigabytePerSecond: return (_value*8d) * 1e9d; - case BitRateUnit.KibibitPerSecond: return (_value) * 1024d; - case BitRateUnit.KibibytePerSecond: return (_value*8d) * 1024d; - case BitRateUnit.KilobitPerSecond: return (_value) * 1e3d; - case BitRateUnit.KilobytePerSecond: return (_value*8d) * 1e3d; - case BitRateUnit.MebibitPerSecond: return (_value) * (1024d * 1024); - case BitRateUnit.MebibytePerSecond: return (_value*8d) * (1024d * 1024); - case BitRateUnit.MegabitPerSecond: return (_value) * 1e6d; - case BitRateUnit.MegabytePerSecond: return (_value*8d) * 1e6d; - case BitRateUnit.PebibitPerSecond: return (_value) * (1024d * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.PebibytePerSecond: return (_value*8d) * (1024d * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.PetabitPerSecond: return (_value) * 1e15d; - case BitRateUnit.PetabytePerSecond: return (_value*8d) * 1e15d; - case BitRateUnit.TebibitPerSecond: return (_value) * (1024d * 1024 * 1024 * 1024); - case BitRateUnit.TebibytePerSecond: return (_value*8d) * (1024d * 1024 * 1024 * 1024); - case BitRateUnit.TerabitPerSecond: return (_value) * 1e12d; - case BitRateUnit.TerabytePerSecond: return (_value*8d) * 1e12d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + BitRateUnit.BitPerSecond => _value, + BitRateUnit.BytePerSecond => _value*8d, + BitRateUnit.ExabitPerSecond => (_value) * 1e18d, + BitRateUnit.ExabytePerSecond => (_value*8d) * 1e18d, + BitRateUnit.ExbibitPerSecond => (_value) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024), + BitRateUnit.ExbibytePerSecond => (_value*8d) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024), + BitRateUnit.GibibitPerSecond => (_value) * (1024d * 1024 * 1024), + BitRateUnit.GibibytePerSecond => (_value*8d) * (1024d * 1024 * 1024), + BitRateUnit.GigabitPerSecond => (_value) * 1e9d, + BitRateUnit.GigabytePerSecond => (_value*8d) * 1e9d, + BitRateUnit.KibibitPerSecond => (_value) * 1024d, + BitRateUnit.KibibytePerSecond => (_value*8d) * 1024d, + BitRateUnit.KilobitPerSecond => (_value) * 1e3d, + BitRateUnit.KilobytePerSecond => (_value*8d) * 1e3d, + BitRateUnit.MebibitPerSecond => (_value) * (1024d * 1024), + BitRateUnit.MebibytePerSecond => (_value*8d) * (1024d * 1024), + BitRateUnit.MegabitPerSecond => (_value) * 1e6d, + BitRateUnit.MegabytePerSecond => (_value*8d) * 1e6d, + BitRateUnit.PebibitPerSecond => (_value) * (1024d * 1024 * 1024 * 1024 * 1024), + BitRateUnit.PebibytePerSecond => (_value*8d) * (1024d * 1024 * 1024 * 1024 * 1024), + BitRateUnit.PetabitPerSecond => (_value) * 1e15d, + BitRateUnit.PetabytePerSecond => (_value*8d) * 1e15d, + BitRateUnit.TebibitPerSecond => (_value) * (1024d * 1024 * 1024 * 1024), + BitRateUnit.TebibytePerSecond => (_value*8d) * (1024d * 1024 * 1024 * 1024), + BitRateUnit.TerabitPerSecond => (_value) * 1e12d, + BitRateUnit.TerabytePerSecond => (_value*8d) * 1e12d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(BitRateUnit unit) @@ -449,37 +448,36 @@ private double GetValueAs(BitRateUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case BitRateUnit.BitPerSecond: return baseUnitValue; - case BitRateUnit.BytePerSecond: return baseUnitValue/8d; - case BitRateUnit.ExabitPerSecond: return (baseUnitValue) / 1e18d; - case BitRateUnit.ExabytePerSecond: return (baseUnitValue/8d) / 1e18d; - case BitRateUnit.ExbibitPerSecond: return (baseUnitValue) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.ExbibytePerSecond: return (baseUnitValue/8d) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.GibibitPerSecond: return (baseUnitValue) / (1024d * 1024 * 1024); - case BitRateUnit.GibibytePerSecond: return (baseUnitValue/8d) / (1024d * 1024 * 1024); - case BitRateUnit.GigabitPerSecond: return (baseUnitValue) / 1e9d; - case BitRateUnit.GigabytePerSecond: return (baseUnitValue/8d) / 1e9d; - case BitRateUnit.KibibitPerSecond: return (baseUnitValue) / 1024d; - case BitRateUnit.KibibytePerSecond: return (baseUnitValue/8d) / 1024d; - case BitRateUnit.KilobitPerSecond: return (baseUnitValue) / 1e3d; - case BitRateUnit.KilobytePerSecond: return (baseUnitValue/8d) / 1e3d; - case BitRateUnit.MebibitPerSecond: return (baseUnitValue) / (1024d * 1024); - case BitRateUnit.MebibytePerSecond: return (baseUnitValue/8d) / (1024d * 1024); - case BitRateUnit.MegabitPerSecond: return (baseUnitValue) / 1e6d; - case BitRateUnit.MegabytePerSecond: return (baseUnitValue/8d) / 1e6d; - case BitRateUnit.PebibitPerSecond: return (baseUnitValue) / (1024d * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.PebibytePerSecond: return (baseUnitValue/8d) / (1024d * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.PetabitPerSecond: return (baseUnitValue) / 1e15d; - case BitRateUnit.PetabytePerSecond: return (baseUnitValue/8d) / 1e15d; - case BitRateUnit.TebibitPerSecond: return (baseUnitValue) / (1024d * 1024 * 1024 * 1024); - case BitRateUnit.TebibytePerSecond: return (baseUnitValue/8d) / (1024d * 1024 * 1024 * 1024); - case BitRateUnit.TerabitPerSecond: return (baseUnitValue) / 1e12d; - case BitRateUnit.TerabytePerSecond: return (baseUnitValue/8d) / 1e12d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + BitRateUnit.BitPerSecond => baseUnitValue, + BitRateUnit.BytePerSecond => baseUnitValue/8d, + BitRateUnit.ExabitPerSecond => (baseUnitValue) / 1e18d, + BitRateUnit.ExabytePerSecond => (baseUnitValue/8d) / 1e18d, + BitRateUnit.ExbibitPerSecond => (baseUnitValue) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024), + BitRateUnit.ExbibytePerSecond => (baseUnitValue/8d) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024), + BitRateUnit.GibibitPerSecond => (baseUnitValue) / (1024d * 1024 * 1024), + BitRateUnit.GibibytePerSecond => (baseUnitValue/8d) / (1024d * 1024 * 1024), + BitRateUnit.GigabitPerSecond => (baseUnitValue) / 1e9d, + BitRateUnit.GigabytePerSecond => (baseUnitValue/8d) / 1e9d, + BitRateUnit.KibibitPerSecond => (baseUnitValue) / 1024d, + BitRateUnit.KibibytePerSecond => (baseUnitValue/8d) / 1024d, + BitRateUnit.KilobitPerSecond => (baseUnitValue) / 1e3d, + BitRateUnit.KilobytePerSecond => (baseUnitValue/8d) / 1e3d, + BitRateUnit.MebibitPerSecond => (baseUnitValue) / (1024d * 1024), + BitRateUnit.MebibytePerSecond => (baseUnitValue/8d) / (1024d * 1024), + BitRateUnit.MegabitPerSecond => (baseUnitValue) / 1e6d, + BitRateUnit.MegabytePerSecond => (baseUnitValue/8d) / 1e6d, + BitRateUnit.PebibitPerSecond => (baseUnitValue) / (1024d * 1024 * 1024 * 1024 * 1024), + BitRateUnit.PebibytePerSecond => (baseUnitValue/8d) / (1024d * 1024 * 1024 * 1024 * 1024), + BitRateUnit.PetabitPerSecond => (baseUnitValue) / 1e15d, + BitRateUnit.PetabytePerSecond => (baseUnitValue/8d) / 1e15d, + BitRateUnit.TebibitPerSecond => (baseUnitValue) / (1024d * 1024 * 1024 * 1024), + BitRateUnit.TebibytePerSecond => (baseUnitValue/8d) / (1024d * 1024 * 1024 * 1024), + BitRateUnit.TerabitPerSecond => (baseUnitValue) / 1e12d, + BitRateUnit.TerabytePerSecond => (baseUnitValue/8d) / 1e12d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 470f9eeddf..ff03cbde59 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -153,14 +153,13 @@ public BrakeSpecificFuelConsumption ToUnit(BrakeSpecificFuelConsumptionUnit unit /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour: return _value/3.6e9; - case BrakeSpecificFuelConsumptionUnit.KilogramPerJoule: return _value; - case BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour: return _value*1.689659410672e-7; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour => _value/3.6e9, + BrakeSpecificFuelConsumptionUnit.KilogramPerJoule => _value, + BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour => _value*1.689659410672e-7, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(BrakeSpecificFuelConsumptionUnit unit) @@ -170,14 +169,13 @@ private double GetValueAs(BrakeSpecificFuelConsumptionUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour: return baseUnitValue*3.6e9; - case BrakeSpecificFuelConsumptionUnit.KilogramPerJoule: return baseUnitValue; - case BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour: return baseUnitValue/1.689659410672e-7; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour => baseUnitValue*3.6e9, + BrakeSpecificFuelConsumptionUnit.KilogramPerJoule => baseUnitValue, + BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour => baseUnitValue/1.689659410672e-7, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Capacitance.g.cs index 0910e6f0c5..dfdb8dcd93 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Capacitance.g.cs @@ -200,18 +200,17 @@ public Capacitance ToUnit(CapacitanceUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case CapacitanceUnit.Farad: return _value; - case CapacitanceUnit.Kilofarad: return (_value) * 1e3d; - case CapacitanceUnit.Megafarad: return (_value) * 1e6d; - case CapacitanceUnit.Microfarad: return (_value) * 1e-6d; - case CapacitanceUnit.Millifarad: return (_value) * 1e-3d; - case CapacitanceUnit.Nanofarad: return (_value) * 1e-9d; - case CapacitanceUnit.Picofarad: return (_value) * 1e-12d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + CapacitanceUnit.Farad => _value, + CapacitanceUnit.Kilofarad => (_value) * 1e3d, + CapacitanceUnit.Megafarad => (_value) * 1e6d, + CapacitanceUnit.Microfarad => (_value) * 1e-6d, + CapacitanceUnit.Millifarad => (_value) * 1e-3d, + CapacitanceUnit.Nanofarad => (_value) * 1e-9d, + CapacitanceUnit.Picofarad => (_value) * 1e-12d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(CapacitanceUnit unit) @@ -221,18 +220,17 @@ private double GetValueAs(CapacitanceUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case CapacitanceUnit.Farad: return baseUnitValue; - case CapacitanceUnit.Kilofarad: return (baseUnitValue) / 1e3d; - case CapacitanceUnit.Megafarad: return (baseUnitValue) / 1e6d; - case CapacitanceUnit.Microfarad: return (baseUnitValue) / 1e-6d; - case CapacitanceUnit.Millifarad: return (baseUnitValue) / 1e-3d; - case CapacitanceUnit.Nanofarad: return (baseUnitValue) / 1e-9d; - case CapacitanceUnit.Picofarad: return (baseUnitValue) / 1e-12d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + CapacitanceUnit.Farad => baseUnitValue, + CapacitanceUnit.Kilofarad => (baseUnitValue) / 1e3d, + CapacitanceUnit.Megafarad => (baseUnitValue) / 1e6d, + CapacitanceUnit.Microfarad => (baseUnitValue) / 1e-6d, + CapacitanceUnit.Millifarad => (baseUnitValue) / 1e-3d, + CapacitanceUnit.Nanofarad => (baseUnitValue) / 1e-9d, + CapacitanceUnit.Picofarad => (baseUnitValue) / 1e-12d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 936fa953a8..ae22dee1a0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -153,14 +153,13 @@ public CoefficientOfThermalExpansion ToUnit(CoefficientOfThermalExpansionUnit un /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case CoefficientOfThermalExpansionUnit.InverseDegreeCelsius: return _value; - case CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit: return _value*9/5; - case CoefficientOfThermalExpansionUnit.InverseKelvin: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + CoefficientOfThermalExpansionUnit.InverseDegreeCelsius => _value, + CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit => _value*9/5, + CoefficientOfThermalExpansionUnit.InverseKelvin => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(CoefficientOfThermalExpansionUnit unit) @@ -170,14 +169,13 @@ private double GetValueAs(CoefficientOfThermalExpansionUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case CoefficientOfThermalExpansionUnit.InverseDegreeCelsius: return baseUnitValue; - case CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit: return baseUnitValue*5/9; - case CoefficientOfThermalExpansionUnit.InverseKelvin: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + CoefficientOfThermalExpansionUnit.InverseDegreeCelsius => baseUnitValue, + CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit => baseUnitValue*5/9, + CoefficientOfThermalExpansionUnit.InverseKelvin => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Density.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Density.g.cs index db87cb6ce9..ff723ba89b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Density.g.cs @@ -684,62 +684,61 @@ public Density ToUnit(DensityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case DensityUnit.CentigramPerDeciliter: return (_value/1e-1) * 1e-2d; - case DensityUnit.CentigramPerLiter: return (_value/1) * 1e-2d; - case DensityUnit.CentigramPerMilliliter: return (_value/1e-3) * 1e-2d; - case DensityUnit.DecigramPerDeciliter: return (_value/1e-1) * 1e-1d; - case DensityUnit.DecigramPerLiter: return (_value/1) * 1e-1d; - case DensityUnit.DecigramPerMilliliter: return (_value/1e-3) * 1e-1d; - case DensityUnit.GramPerCubicCentimeter: return _value/1e-3; - case DensityUnit.GramPerCubicFoot: return _value*0.0353146667214886; - case DensityUnit.GramPerCubicInch: return _value*61.0237440947323; - case DensityUnit.GramPerCubicMeter: return _value/1e3; - case DensityUnit.GramPerCubicMillimeter: return _value/1e-6; - case DensityUnit.GramPerDeciliter: return _value/1e-1; - case DensityUnit.GramPerLiter: return _value/1; - case DensityUnit.GramPerMilliliter: return _value/1e-3; - case DensityUnit.KilogramPerCubicCentimeter: return (_value/1e-3) * 1e3d; - case DensityUnit.KilogramPerCubicMeter: return (_value/1e3) * 1e3d; - case DensityUnit.KilogramPerCubicMillimeter: return (_value/1e-6) * 1e3d; - case DensityUnit.KilogramPerLiter: return _value*1e3; - case DensityUnit.KilopoundPerCubicFoot: return (_value/0.062427961) * 1e3d; - case DensityUnit.KilopoundPerCubicInch: return (_value/3.6127298147753e-5) * 1e3d; - case DensityUnit.MicrogramPerCubicMeter: return (_value/1e3) * 1e-6d; - case DensityUnit.MicrogramPerDeciliter: return (_value/1e-1) * 1e-6d; - case DensityUnit.MicrogramPerLiter: return (_value/1) * 1e-6d; - case DensityUnit.MicrogramPerMilliliter: return (_value/1e-3) * 1e-6d; - case DensityUnit.MilligramPerCubicMeter: return (_value/1e3) * 1e-3d; - case DensityUnit.MilligramPerDeciliter: return (_value/1e-1) * 1e-3d; - case DensityUnit.MilligramPerLiter: return (_value/1) * 1e-3d; - case DensityUnit.MilligramPerMilliliter: return (_value/1e-3) * 1e-3d; - case DensityUnit.NanogramPerDeciliter: return (_value/1e-1) * 1e-9d; - case DensityUnit.NanogramPerLiter: return (_value/1) * 1e-9d; - case DensityUnit.NanogramPerMilliliter: return (_value/1e-3) * 1e-9d; - case DensityUnit.PicogramPerDeciliter: return (_value/1e-1) * 1e-12d; - case DensityUnit.PicogramPerLiter: return (_value/1) * 1e-12d; - case DensityUnit.PicogramPerMilliliter: return (_value/1e-3) * 1e-12d; - case DensityUnit.PoundPerCubicCentimeter: return _value/2.204622621848775e-6; - case DensityUnit.PoundPerCubicFoot: return _value/0.062427961; - case DensityUnit.PoundPerCubicInch: return _value/3.6127298147753e-5; - case DensityUnit.PoundPerCubicMeter: return _value/2.204622621848775; - case DensityUnit.PoundPerCubicMillimeter: return _value/2.204622621848775e-9; - case DensityUnit.PoundPerImperialGallon: return _value*9.9776398e1; - case DensityUnit.PoundPerUSGallon: return _value*1.19826427e2; - case DensityUnit.SlugPerCubicCentimeter: return _value*14593903; - case DensityUnit.SlugPerCubicFoot: return _value*515.378818; - case DensityUnit.SlugPerCubicInch: return _value*890574.60201535; - case DensityUnit.SlugPerCubicMeter: return _value*14.5939; - case DensityUnit.SlugPerCubicMillimeter: return _value*14593903000; - case DensityUnit.TonnePerCubicCentimeter: return _value/1e-9; - case DensityUnit.TonnePerCubicFoot: return _value*3.53146667214886e4; - case DensityUnit.TonnePerCubicInch: return _value*6.10237440947323e7; - case DensityUnit.TonnePerCubicMeter: return _value/0.001; - case DensityUnit.TonnePerCubicMillimeter: return _value/1e-12; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + DensityUnit.CentigramPerDeciliter => (_value/1e-1) * 1e-2d, + DensityUnit.CentigramPerLiter => (_value/1) * 1e-2d, + DensityUnit.CentigramPerMilliliter => (_value/1e-3) * 1e-2d, + DensityUnit.DecigramPerDeciliter => (_value/1e-1) * 1e-1d, + DensityUnit.DecigramPerLiter => (_value/1) * 1e-1d, + DensityUnit.DecigramPerMilliliter => (_value/1e-3) * 1e-1d, + DensityUnit.GramPerCubicCentimeter => _value/1e-3, + DensityUnit.GramPerCubicFoot => _value*0.0353146667214886, + DensityUnit.GramPerCubicInch => _value*61.0237440947323, + DensityUnit.GramPerCubicMeter => _value/1e3, + DensityUnit.GramPerCubicMillimeter => _value/1e-6, + DensityUnit.GramPerDeciliter => _value/1e-1, + DensityUnit.GramPerLiter => _value/1, + DensityUnit.GramPerMilliliter => _value/1e-3, + DensityUnit.KilogramPerCubicCentimeter => (_value/1e-3) * 1e3d, + DensityUnit.KilogramPerCubicMeter => (_value/1e3) * 1e3d, + DensityUnit.KilogramPerCubicMillimeter => (_value/1e-6) * 1e3d, + DensityUnit.KilogramPerLiter => _value*1e3, + DensityUnit.KilopoundPerCubicFoot => (_value/0.062427961) * 1e3d, + DensityUnit.KilopoundPerCubicInch => (_value/3.6127298147753e-5) * 1e3d, + DensityUnit.MicrogramPerCubicMeter => (_value/1e3) * 1e-6d, + DensityUnit.MicrogramPerDeciliter => (_value/1e-1) * 1e-6d, + DensityUnit.MicrogramPerLiter => (_value/1) * 1e-6d, + DensityUnit.MicrogramPerMilliliter => (_value/1e-3) * 1e-6d, + DensityUnit.MilligramPerCubicMeter => (_value/1e3) * 1e-3d, + DensityUnit.MilligramPerDeciliter => (_value/1e-1) * 1e-3d, + DensityUnit.MilligramPerLiter => (_value/1) * 1e-3d, + DensityUnit.MilligramPerMilliliter => (_value/1e-3) * 1e-3d, + DensityUnit.NanogramPerDeciliter => (_value/1e-1) * 1e-9d, + DensityUnit.NanogramPerLiter => (_value/1) * 1e-9d, + DensityUnit.NanogramPerMilliliter => (_value/1e-3) * 1e-9d, + DensityUnit.PicogramPerDeciliter => (_value/1e-1) * 1e-12d, + DensityUnit.PicogramPerLiter => (_value/1) * 1e-12d, + DensityUnit.PicogramPerMilliliter => (_value/1e-3) * 1e-12d, + DensityUnit.PoundPerCubicCentimeter => _value/2.204622621848775e-6, + DensityUnit.PoundPerCubicFoot => _value/0.062427961, + DensityUnit.PoundPerCubicInch => _value/3.6127298147753e-5, + DensityUnit.PoundPerCubicMeter => _value/2.204622621848775, + DensityUnit.PoundPerCubicMillimeter => _value/2.204622621848775e-9, + DensityUnit.PoundPerImperialGallon => _value*9.9776398e1, + DensityUnit.PoundPerUSGallon => _value*1.19826427e2, + DensityUnit.SlugPerCubicCentimeter => _value*14593903, + DensityUnit.SlugPerCubicFoot => _value*515.378818, + DensityUnit.SlugPerCubicInch => _value*890574.60201535, + DensityUnit.SlugPerCubicMeter => _value*14.5939, + DensityUnit.SlugPerCubicMillimeter => _value*14593903000, + DensityUnit.TonnePerCubicCentimeter => _value/1e-9, + DensityUnit.TonnePerCubicFoot => _value*3.53146667214886e4, + DensityUnit.TonnePerCubicInch => _value*6.10237440947323e7, + DensityUnit.TonnePerCubicMeter => _value/0.001, + DensityUnit.TonnePerCubicMillimeter => _value/1e-12, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(DensityUnit unit) @@ -749,62 +748,61 @@ private double GetValueAs(DensityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case DensityUnit.CentigramPerDeciliter: return (baseUnitValue*1e-1) / 1e-2d; - case DensityUnit.CentigramPerLiter: return (baseUnitValue*1) / 1e-2d; - case DensityUnit.CentigramPerMilliliter: return (baseUnitValue*1e-3) / 1e-2d; - case DensityUnit.DecigramPerDeciliter: return (baseUnitValue*1e-1) / 1e-1d; - case DensityUnit.DecigramPerLiter: return (baseUnitValue*1) / 1e-1d; - case DensityUnit.DecigramPerMilliliter: return (baseUnitValue*1e-3) / 1e-1d; - case DensityUnit.GramPerCubicCentimeter: return baseUnitValue*1e-3; - case DensityUnit.GramPerCubicFoot: return baseUnitValue/0.0353146667214886; - case DensityUnit.GramPerCubicInch: return baseUnitValue/61.0237440947323; - case DensityUnit.GramPerCubicMeter: return baseUnitValue*1e3; - case DensityUnit.GramPerCubicMillimeter: return baseUnitValue*1e-6; - case DensityUnit.GramPerDeciliter: return baseUnitValue*1e-1; - case DensityUnit.GramPerLiter: return baseUnitValue*1; - case DensityUnit.GramPerMilliliter: return baseUnitValue*1e-3; - case DensityUnit.KilogramPerCubicCentimeter: return (baseUnitValue*1e-3) / 1e3d; - case DensityUnit.KilogramPerCubicMeter: return (baseUnitValue*1e3) / 1e3d; - case DensityUnit.KilogramPerCubicMillimeter: return (baseUnitValue*1e-6) / 1e3d; - case DensityUnit.KilogramPerLiter: return baseUnitValue/1e3; - case DensityUnit.KilopoundPerCubicFoot: return (baseUnitValue*0.062427961) / 1e3d; - case DensityUnit.KilopoundPerCubicInch: return (baseUnitValue*3.6127298147753e-5) / 1e3d; - case DensityUnit.MicrogramPerCubicMeter: return (baseUnitValue*1e3) / 1e-6d; - case DensityUnit.MicrogramPerDeciliter: return (baseUnitValue*1e-1) / 1e-6d; - case DensityUnit.MicrogramPerLiter: return (baseUnitValue*1) / 1e-6d; - case DensityUnit.MicrogramPerMilliliter: return (baseUnitValue*1e-3) / 1e-6d; - case DensityUnit.MilligramPerCubicMeter: return (baseUnitValue*1e3) / 1e-3d; - case DensityUnit.MilligramPerDeciliter: return (baseUnitValue*1e-1) / 1e-3d; - case DensityUnit.MilligramPerLiter: return (baseUnitValue*1) / 1e-3d; - case DensityUnit.MilligramPerMilliliter: return (baseUnitValue*1e-3) / 1e-3d; - case DensityUnit.NanogramPerDeciliter: return (baseUnitValue*1e-1) / 1e-9d; - case DensityUnit.NanogramPerLiter: return (baseUnitValue*1) / 1e-9d; - case DensityUnit.NanogramPerMilliliter: return (baseUnitValue*1e-3) / 1e-9d; - case DensityUnit.PicogramPerDeciliter: return (baseUnitValue*1e-1) / 1e-12d; - case DensityUnit.PicogramPerLiter: return (baseUnitValue*1) / 1e-12d; - case DensityUnit.PicogramPerMilliliter: return (baseUnitValue*1e-3) / 1e-12d; - case DensityUnit.PoundPerCubicCentimeter: return baseUnitValue*2.204622621848775e-6; - case DensityUnit.PoundPerCubicFoot: return baseUnitValue*0.062427961; - case DensityUnit.PoundPerCubicInch: return baseUnitValue*3.6127298147753e-5; - case DensityUnit.PoundPerCubicMeter: return baseUnitValue*2.204622621848775; - case DensityUnit.PoundPerCubicMillimeter: return baseUnitValue*2.204622621848775e-9; - case DensityUnit.PoundPerImperialGallon: return baseUnitValue/9.9776398e1; - case DensityUnit.PoundPerUSGallon: return baseUnitValue/1.19826427e2; - case DensityUnit.SlugPerCubicCentimeter: return baseUnitValue/14593903; - case DensityUnit.SlugPerCubicFoot: return baseUnitValue*0.00194032033; - case DensityUnit.SlugPerCubicInch: return baseUnitValue/890574.60201535; - case DensityUnit.SlugPerCubicMeter: return baseUnitValue/14.5939; - case DensityUnit.SlugPerCubicMillimeter: return baseUnitValue/14593903000; - case DensityUnit.TonnePerCubicCentimeter: return baseUnitValue*1e-9; - case DensityUnit.TonnePerCubicFoot: return baseUnitValue/3.53146667214886e4; - case DensityUnit.TonnePerCubicInch: return baseUnitValue/6.10237440947323e7; - case DensityUnit.TonnePerCubicMeter: return baseUnitValue*0.001; - case DensityUnit.TonnePerCubicMillimeter: return baseUnitValue*1e-12; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + DensityUnit.CentigramPerDeciliter => (baseUnitValue*1e-1) / 1e-2d, + DensityUnit.CentigramPerLiter => (baseUnitValue*1) / 1e-2d, + DensityUnit.CentigramPerMilliliter => (baseUnitValue*1e-3) / 1e-2d, + DensityUnit.DecigramPerDeciliter => (baseUnitValue*1e-1) / 1e-1d, + DensityUnit.DecigramPerLiter => (baseUnitValue*1) / 1e-1d, + DensityUnit.DecigramPerMilliliter => (baseUnitValue*1e-3) / 1e-1d, + DensityUnit.GramPerCubicCentimeter => baseUnitValue*1e-3, + DensityUnit.GramPerCubicFoot => baseUnitValue/0.0353146667214886, + DensityUnit.GramPerCubicInch => baseUnitValue/61.0237440947323, + DensityUnit.GramPerCubicMeter => baseUnitValue*1e3, + DensityUnit.GramPerCubicMillimeter => baseUnitValue*1e-6, + DensityUnit.GramPerDeciliter => baseUnitValue*1e-1, + DensityUnit.GramPerLiter => baseUnitValue*1, + DensityUnit.GramPerMilliliter => baseUnitValue*1e-3, + DensityUnit.KilogramPerCubicCentimeter => (baseUnitValue*1e-3) / 1e3d, + DensityUnit.KilogramPerCubicMeter => (baseUnitValue*1e3) / 1e3d, + DensityUnit.KilogramPerCubicMillimeter => (baseUnitValue*1e-6) / 1e3d, + DensityUnit.KilogramPerLiter => baseUnitValue/1e3, + DensityUnit.KilopoundPerCubicFoot => (baseUnitValue*0.062427961) / 1e3d, + DensityUnit.KilopoundPerCubicInch => (baseUnitValue*3.6127298147753e-5) / 1e3d, + DensityUnit.MicrogramPerCubicMeter => (baseUnitValue*1e3) / 1e-6d, + DensityUnit.MicrogramPerDeciliter => (baseUnitValue*1e-1) / 1e-6d, + DensityUnit.MicrogramPerLiter => (baseUnitValue*1) / 1e-6d, + DensityUnit.MicrogramPerMilliliter => (baseUnitValue*1e-3) / 1e-6d, + DensityUnit.MilligramPerCubicMeter => (baseUnitValue*1e3) / 1e-3d, + DensityUnit.MilligramPerDeciliter => (baseUnitValue*1e-1) / 1e-3d, + DensityUnit.MilligramPerLiter => (baseUnitValue*1) / 1e-3d, + DensityUnit.MilligramPerMilliliter => (baseUnitValue*1e-3) / 1e-3d, + DensityUnit.NanogramPerDeciliter => (baseUnitValue*1e-1) / 1e-9d, + DensityUnit.NanogramPerLiter => (baseUnitValue*1) / 1e-9d, + DensityUnit.NanogramPerMilliliter => (baseUnitValue*1e-3) / 1e-9d, + DensityUnit.PicogramPerDeciliter => (baseUnitValue*1e-1) / 1e-12d, + DensityUnit.PicogramPerLiter => (baseUnitValue*1) / 1e-12d, + DensityUnit.PicogramPerMilliliter => (baseUnitValue*1e-3) / 1e-12d, + DensityUnit.PoundPerCubicCentimeter => baseUnitValue*2.204622621848775e-6, + DensityUnit.PoundPerCubicFoot => baseUnitValue*0.062427961, + DensityUnit.PoundPerCubicInch => baseUnitValue*3.6127298147753e-5, + DensityUnit.PoundPerCubicMeter => baseUnitValue*2.204622621848775, + DensityUnit.PoundPerCubicMillimeter => baseUnitValue*2.204622621848775e-9, + DensityUnit.PoundPerImperialGallon => baseUnitValue/9.9776398e1, + DensityUnit.PoundPerUSGallon => baseUnitValue/1.19826427e2, + DensityUnit.SlugPerCubicCentimeter => baseUnitValue/14593903, + DensityUnit.SlugPerCubicFoot => baseUnitValue*0.00194032033, + DensityUnit.SlugPerCubicInch => baseUnitValue/890574.60201535, + DensityUnit.SlugPerCubicMeter => baseUnitValue/14.5939, + DensityUnit.SlugPerCubicMillimeter => baseUnitValue/14593903000, + DensityUnit.TonnePerCubicCentimeter => baseUnitValue*1e-9, + DensityUnit.TonnePerCubicFoot => baseUnitValue/3.53146667214886e4, + DensityUnit.TonnePerCubicInch => baseUnitValue/6.10237440947323e7, + DensityUnit.TonnePerCubicMeter => baseUnitValue*0.001, + DensityUnit.TonnePerCubicMillimeter => baseUnitValue*1e-12, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Duration.g.cs index 6faa2205b6..9d58dce1b0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Duration.g.cs @@ -241,22 +241,21 @@ public Duration ToUnit(DurationUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case DurationUnit.Day: return _value*24*3600; - case DurationUnit.Hour: return _value*3600; - case DurationUnit.JulianYear: return _value*365.25*24*3600; - case DurationUnit.Microsecond: return (_value) * 1e-6d; - case DurationUnit.Millisecond: return (_value) * 1e-3d; - case DurationUnit.Minute: return _value*60; - case DurationUnit.Month30: return _value*30*24*3600; - case DurationUnit.Nanosecond: return (_value) * 1e-9d; - case DurationUnit.Second: return _value; - case DurationUnit.Week: return _value*7*24*3600; - case DurationUnit.Year365: return _value*365*24*3600; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + DurationUnit.Day => _value*24*3600, + DurationUnit.Hour => _value*3600, + DurationUnit.JulianYear => _value*365.25*24*3600, + DurationUnit.Microsecond => (_value) * 1e-6d, + DurationUnit.Millisecond => (_value) * 1e-3d, + DurationUnit.Minute => _value*60, + DurationUnit.Month30 => _value*30*24*3600, + DurationUnit.Nanosecond => (_value) * 1e-9d, + DurationUnit.Second => _value, + DurationUnit.Week => _value*7*24*3600, + DurationUnit.Year365 => _value*365*24*3600, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(DurationUnit unit) @@ -266,22 +265,21 @@ private double GetValueAs(DurationUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case DurationUnit.Day: return baseUnitValue/(24*3600); - case DurationUnit.Hour: return baseUnitValue/3600; - case DurationUnit.JulianYear: return baseUnitValue/(365.25*24*3600); - case DurationUnit.Microsecond: return (baseUnitValue) / 1e-6d; - case DurationUnit.Millisecond: return (baseUnitValue) / 1e-3d; - case DurationUnit.Minute: return baseUnitValue/60; - case DurationUnit.Month30: return baseUnitValue/(30*24*3600); - case DurationUnit.Nanosecond: return (baseUnitValue) / 1e-9d; - case DurationUnit.Second: return baseUnitValue; - case DurationUnit.Week: return baseUnitValue/(7*24*3600); - case DurationUnit.Year365: return baseUnitValue/(365*24*3600); - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + DurationUnit.Day => baseUnitValue/(24*3600), + DurationUnit.Hour => baseUnitValue/3600, + DurationUnit.JulianYear => baseUnitValue/(365.25*24*3600), + DurationUnit.Microsecond => (baseUnitValue) / 1e-6d, + DurationUnit.Millisecond => (baseUnitValue) / 1e-3d, + DurationUnit.Minute => baseUnitValue/60, + DurationUnit.Month30 => baseUnitValue/(30*24*3600), + DurationUnit.Nanosecond => (baseUnitValue) / 1e-9d, + DurationUnit.Second => baseUnitValue, + DurationUnit.Week => baseUnitValue/(7*24*3600), + DurationUnit.Year365 => baseUnitValue/(365*24*3600), + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/DynamicViscosity.g.cs index 042151ce40..edc6800e73 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -233,21 +233,20 @@ public DynamicViscosity ToUnit(DynamicViscosityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case DynamicViscosityUnit.Centipoise: return (_value/10) * 1e-2d; - case DynamicViscosityUnit.MicropascalSecond: return (_value) * 1e-6d; - case DynamicViscosityUnit.MillipascalSecond: return (_value) * 1e-3d; - case DynamicViscosityUnit.NewtonSecondPerMeterSquared: return _value; - case DynamicViscosityUnit.PascalSecond: return _value; - case DynamicViscosityUnit.Poise: return _value/10; - case DynamicViscosityUnit.PoundForceSecondPerSquareFoot: return _value * 4.7880258980335843e1; - case DynamicViscosityUnit.PoundForceSecondPerSquareInch: return _value * 6.8947572931683613e3; - case DynamicViscosityUnit.PoundPerFootSecond: return _value * 1.4881639; - case DynamicViscosityUnit.Reyn: return _value * 6.8947572931683613e3; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + DynamicViscosityUnit.Centipoise => (_value/10) * 1e-2d, + DynamicViscosityUnit.MicropascalSecond => (_value) * 1e-6d, + DynamicViscosityUnit.MillipascalSecond => (_value) * 1e-3d, + DynamicViscosityUnit.NewtonSecondPerMeterSquared => _value, + DynamicViscosityUnit.PascalSecond => _value, + DynamicViscosityUnit.Poise => _value/10, + DynamicViscosityUnit.PoundForceSecondPerSquareFoot => _value * 4.7880258980335843e1, + DynamicViscosityUnit.PoundForceSecondPerSquareInch => _value * 6.8947572931683613e3, + DynamicViscosityUnit.PoundPerFootSecond => _value * 1.4881639, + DynamicViscosityUnit.Reyn => _value * 6.8947572931683613e3, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(DynamicViscosityUnit unit) @@ -257,21 +256,20 @@ private double GetValueAs(DynamicViscosityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case DynamicViscosityUnit.Centipoise: return (baseUnitValue*10) / 1e-2d; - case DynamicViscosityUnit.MicropascalSecond: return (baseUnitValue) / 1e-6d; - case DynamicViscosityUnit.MillipascalSecond: return (baseUnitValue) / 1e-3d; - case DynamicViscosityUnit.NewtonSecondPerMeterSquared: return baseUnitValue; - case DynamicViscosityUnit.PascalSecond: return baseUnitValue; - case DynamicViscosityUnit.Poise: return baseUnitValue*10; - case DynamicViscosityUnit.PoundForceSecondPerSquareFoot: return baseUnitValue / 4.7880258980335843e1; - case DynamicViscosityUnit.PoundForceSecondPerSquareInch: return baseUnitValue / 6.8947572931683613e3; - case DynamicViscosityUnit.PoundPerFootSecond: return baseUnitValue / 1.4881639; - case DynamicViscosityUnit.Reyn: return baseUnitValue / 6.8947572931683613e3; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + DynamicViscosityUnit.Centipoise => (baseUnitValue*10) / 1e-2d, + DynamicViscosityUnit.MicropascalSecond => (baseUnitValue) / 1e-6d, + DynamicViscosityUnit.MillipascalSecond => (baseUnitValue) / 1e-3d, + DynamicViscosityUnit.NewtonSecondPerMeterSquared => baseUnitValue, + DynamicViscosityUnit.PascalSecond => baseUnitValue, + DynamicViscosityUnit.Poise => baseUnitValue*10, + DynamicViscosityUnit.PoundForceSecondPerSquareFoot => baseUnitValue / 4.7880258980335843e1, + DynamicViscosityUnit.PoundForceSecondPerSquareInch => baseUnitValue / 6.8947572931683613e3, + DynamicViscosityUnit.PoundPerFootSecond => baseUnitValue / 1.4881639, + DynamicViscosityUnit.Reyn => baseUnitValue / 6.8947572931683613e3, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricAdmittance.g.cs index c750e3cec8..e53bc7e011 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -164,15 +164,14 @@ public ElectricAdmittance ToUnit(ElectricAdmittanceUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ElectricAdmittanceUnit.Microsiemens: return (_value) * 1e-6d; - case ElectricAdmittanceUnit.Millisiemens: return (_value) * 1e-3d; - case ElectricAdmittanceUnit.Nanosiemens: return (_value) * 1e-9d; - case ElectricAdmittanceUnit.Siemens: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ElectricAdmittanceUnit.Microsiemens => (_value) * 1e-6d, + ElectricAdmittanceUnit.Millisiemens => (_value) * 1e-3d, + ElectricAdmittanceUnit.Nanosiemens => (_value) * 1e-9d, + ElectricAdmittanceUnit.Siemens => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ElectricAdmittanceUnit unit) @@ -182,15 +181,14 @@ private double GetValueAs(ElectricAdmittanceUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ElectricAdmittanceUnit.Microsiemens: return (baseUnitValue) / 1e-6d; - case ElectricAdmittanceUnit.Millisiemens: return (baseUnitValue) / 1e-3d; - case ElectricAdmittanceUnit.Nanosiemens: return (baseUnitValue) / 1e-9d; - case ElectricAdmittanceUnit.Siemens: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ElectricAdmittanceUnit.Microsiemens => (baseUnitValue) / 1e-6d, + ElectricAdmittanceUnit.Millisiemens => (baseUnitValue) / 1e-3d, + ElectricAdmittanceUnit.Nanosiemens => (baseUnitValue) / 1e-9d, + ElectricAdmittanceUnit.Siemens => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs index 4186a6609c..68dcefed3c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -178,16 +178,15 @@ public ElectricCharge ToUnit(ElectricChargeUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ElectricChargeUnit.AmpereHour: return _value/2.77777777777e-4; - case ElectricChargeUnit.Coulomb: return _value; - case ElectricChargeUnit.KiloampereHour: return (_value/2.77777777777e-4) * 1e3d; - case ElectricChargeUnit.MegaampereHour: return (_value/2.77777777777e-4) * 1e6d; - case ElectricChargeUnit.MilliampereHour: return (_value/2.77777777777e-4) * 1e-3d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ElectricChargeUnit.AmpereHour => _value/2.77777777777e-4, + ElectricChargeUnit.Coulomb => _value, + ElectricChargeUnit.KiloampereHour => (_value/2.77777777777e-4) * 1e3d, + ElectricChargeUnit.MegaampereHour => (_value/2.77777777777e-4) * 1e6d, + ElectricChargeUnit.MilliampereHour => (_value/2.77777777777e-4) * 1e-3d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ElectricChargeUnit unit) @@ -197,16 +196,15 @@ private double GetValueAs(ElectricChargeUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ElectricChargeUnit.AmpereHour: return baseUnitValue*2.77777777777e-4; - case ElectricChargeUnit.Coulomb: return baseUnitValue; - case ElectricChargeUnit.KiloampereHour: return (baseUnitValue*2.77777777777e-4) / 1e3d; - case ElectricChargeUnit.MegaampereHour: return (baseUnitValue*2.77777777777e-4) / 1e6d; - case ElectricChargeUnit.MilliampereHour: return (baseUnitValue*2.77777777777e-4) / 1e-3d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ElectricChargeUnit.AmpereHour => baseUnitValue*2.77777777777e-4, + ElectricChargeUnit.Coulomb => baseUnitValue, + ElectricChargeUnit.KiloampereHour => (baseUnitValue*2.77777777777e-4) / 1e3d, + ElectricChargeUnit.MegaampereHour => (baseUnitValue*2.77777777777e-4) / 1e6d, + ElectricChargeUnit.MilliampereHour => (baseUnitValue*2.77777777777e-4) / 1e-3d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index af00e069b6..f94195dab3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -134,12 +134,11 @@ public ElectricChargeDensity ToUnit(ElectricChargeDensityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ElectricChargeDensityUnit.CoulombPerCubicMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ElectricChargeDensityUnit.CoulombPerCubicMeter => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ElectricChargeDensityUnit unit) @@ -149,12 +148,11 @@ private double GetValueAs(ElectricChargeDensityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ElectricChargeDensityUnit.CoulombPerCubicMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ElectricChargeDensityUnit.CoulombPerCubicMeter => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductance.g.cs index 5db3b49c45..1673d08a44 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -156,14 +156,13 @@ public ElectricConductance ToUnit(ElectricConductanceUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ElectricConductanceUnit.Microsiemens: return (_value) * 1e-6d; - case ElectricConductanceUnit.Millisiemens: return (_value) * 1e-3d; - case ElectricConductanceUnit.Siemens: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ElectricConductanceUnit.Microsiemens => (_value) * 1e-6d, + ElectricConductanceUnit.Millisiemens => (_value) * 1e-3d, + ElectricConductanceUnit.Siemens => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ElectricConductanceUnit unit) @@ -173,14 +172,13 @@ private double GetValueAs(ElectricConductanceUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ElectricConductanceUnit.Microsiemens: return (baseUnitValue) / 1e-6d; - case ElectricConductanceUnit.Millisiemens: return (baseUnitValue) / 1e-3d; - case ElectricConductanceUnit.Siemens: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ElectricConductanceUnit.Microsiemens => (baseUnitValue) / 1e-6d, + ElectricConductanceUnit.Millisiemens => (baseUnitValue) / 1e-3d, + ElectricConductanceUnit.Siemens => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductivity.g.cs index cf4a999e48..24d6812194 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -156,14 +156,13 @@ public ElectricConductivity ToUnit(ElectricConductivityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ElectricConductivityUnit.SiemensPerFoot: return _value * 3.2808398950131234; - case ElectricConductivityUnit.SiemensPerInch: return _value * 3.937007874015748e1; - case ElectricConductivityUnit.SiemensPerMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ElectricConductivityUnit.SiemensPerFoot => _value * 3.2808398950131234, + ElectricConductivityUnit.SiemensPerInch => _value * 3.937007874015748e1, + ElectricConductivityUnit.SiemensPerMeter => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ElectricConductivityUnit unit) @@ -173,14 +172,13 @@ private double GetValueAs(ElectricConductivityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ElectricConductivityUnit.SiemensPerFoot: return baseUnitValue / 3.2808398950131234; - case ElectricConductivityUnit.SiemensPerInch: return baseUnitValue / 3.937007874015748e1; - case ElectricConductivityUnit.SiemensPerMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ElectricConductivityUnit.SiemensPerFoot => baseUnitValue / 3.2808398950131234, + ElectricConductivityUnit.SiemensPerInch => baseUnitValue / 3.937007874015748e1, + ElectricConductivityUnit.SiemensPerMeter => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrent.g.cs index 77c9b67ef4..30fb382922 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -208,19 +208,18 @@ public ElectricCurrent ToUnit(ElectricCurrentUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ElectricCurrentUnit.Ampere: return _value; - case ElectricCurrentUnit.Centiampere: return (_value) * 1e-2d; - case ElectricCurrentUnit.Kiloampere: return (_value) * 1e3d; - case ElectricCurrentUnit.Megaampere: return (_value) * 1e6d; - case ElectricCurrentUnit.Microampere: return (_value) * 1e-6d; - case ElectricCurrentUnit.Milliampere: return (_value) * 1e-3d; - case ElectricCurrentUnit.Nanoampere: return (_value) * 1e-9d; - case ElectricCurrentUnit.Picoampere: return (_value) * 1e-12d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ElectricCurrentUnit.Ampere => _value, + ElectricCurrentUnit.Centiampere => (_value) * 1e-2d, + ElectricCurrentUnit.Kiloampere => (_value) * 1e3d, + ElectricCurrentUnit.Megaampere => (_value) * 1e6d, + ElectricCurrentUnit.Microampere => (_value) * 1e-6d, + ElectricCurrentUnit.Milliampere => (_value) * 1e-3d, + ElectricCurrentUnit.Nanoampere => (_value) * 1e-9d, + ElectricCurrentUnit.Picoampere => (_value) * 1e-12d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ElectricCurrentUnit unit) @@ -230,19 +229,18 @@ private double GetValueAs(ElectricCurrentUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ElectricCurrentUnit.Ampere: return baseUnitValue; - case ElectricCurrentUnit.Centiampere: return (baseUnitValue) / 1e-2d; - case ElectricCurrentUnit.Kiloampere: return (baseUnitValue) / 1e3d; - case ElectricCurrentUnit.Megaampere: return (baseUnitValue) / 1e6d; - case ElectricCurrentUnit.Microampere: return (baseUnitValue) / 1e-6d; - case ElectricCurrentUnit.Milliampere: return (baseUnitValue) / 1e-3d; - case ElectricCurrentUnit.Nanoampere: return (baseUnitValue) / 1e-9d; - case ElectricCurrentUnit.Picoampere: return (baseUnitValue) / 1e-12d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ElectricCurrentUnit.Ampere => baseUnitValue, + ElectricCurrentUnit.Centiampere => (baseUnitValue) / 1e-2d, + ElectricCurrentUnit.Kiloampere => (baseUnitValue) / 1e3d, + ElectricCurrentUnit.Megaampere => (baseUnitValue) / 1e6d, + ElectricCurrentUnit.Microampere => (baseUnitValue) / 1e-6d, + ElectricCurrentUnit.Milliampere => (baseUnitValue) / 1e-3d, + ElectricCurrentUnit.Nanoampere => (baseUnitValue) / 1e-9d, + ElectricCurrentUnit.Picoampere => (baseUnitValue) / 1e-12d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index cb8f017dd3..0c2da141d6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -156,14 +156,13 @@ public ElectricCurrentDensity ToUnit(ElectricCurrentDensityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ElectricCurrentDensityUnit.AmperePerSquareFoot: return _value * 1.0763910416709722e1; - case ElectricCurrentDensityUnit.AmperePerSquareInch: return _value * 1.5500031000062000e3; - case ElectricCurrentDensityUnit.AmperePerSquareMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ElectricCurrentDensityUnit.AmperePerSquareFoot => _value * 1.0763910416709722e1, + ElectricCurrentDensityUnit.AmperePerSquareInch => _value * 1.5500031000062000e3, + ElectricCurrentDensityUnit.AmperePerSquareMeter => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ElectricCurrentDensityUnit unit) @@ -173,14 +172,13 @@ private double GetValueAs(ElectricCurrentDensityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ElectricCurrentDensityUnit.AmperePerSquareFoot: return baseUnitValue / 1.0763910416709722e1; - case ElectricCurrentDensityUnit.AmperePerSquareInch: return baseUnitValue / 1.5500031000062000e3; - case ElectricCurrentDensityUnit.AmperePerSquareMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ElectricCurrentDensityUnit.AmperePerSquareFoot => baseUnitValue / 1.0763910416709722e1, + ElectricCurrentDensityUnit.AmperePerSquareInch => baseUnitValue / 1.5500031000062000e3, + ElectricCurrentDensityUnit.AmperePerSquareMeter => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index c0911be472..5ee5aaa841 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -164,15 +164,14 @@ public ElectricCurrentGradient ToUnit(ElectricCurrentGradientUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ElectricCurrentGradientUnit.AmperePerMicrosecond: return _value*1E6; - case ElectricCurrentGradientUnit.AmperePerMillisecond: return _value*1E3; - case ElectricCurrentGradientUnit.AmperePerNanosecond: return _value*1E9; - case ElectricCurrentGradientUnit.AmperePerSecond: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ElectricCurrentGradientUnit.AmperePerMicrosecond => _value*1E6, + ElectricCurrentGradientUnit.AmperePerMillisecond => _value*1E3, + ElectricCurrentGradientUnit.AmperePerNanosecond => _value*1E9, + ElectricCurrentGradientUnit.AmperePerSecond => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ElectricCurrentGradientUnit unit) @@ -182,15 +181,14 @@ private double GetValueAs(ElectricCurrentGradientUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ElectricCurrentGradientUnit.AmperePerMicrosecond: return baseUnitValue/1E6; - case ElectricCurrentGradientUnit.AmperePerMillisecond: return baseUnitValue/1E3; - case ElectricCurrentGradientUnit.AmperePerNanosecond: return baseUnitValue/1E9; - case ElectricCurrentGradientUnit.AmperePerSecond: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ElectricCurrentGradientUnit.AmperePerMicrosecond => baseUnitValue/1E6, + ElectricCurrentGradientUnit.AmperePerMillisecond => baseUnitValue/1E3, + ElectricCurrentGradientUnit.AmperePerNanosecond => baseUnitValue/1E9, + ElectricCurrentGradientUnit.AmperePerSecond => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricField.g.cs index 9e9f454c45..fa90ac6f64 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricField.g.cs @@ -134,12 +134,11 @@ public ElectricField ToUnit(ElectricFieldUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ElectricFieldUnit.VoltPerMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ElectricFieldUnit.VoltPerMeter => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ElectricFieldUnit unit) @@ -149,12 +148,11 @@ private double GetValueAs(ElectricFieldUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ElectricFieldUnit.VoltPerMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ElectricFieldUnit.VoltPerMeter => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricInductance.g.cs index 6d92c3dc49..8ed8bccd66 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -167,15 +167,14 @@ public ElectricInductance ToUnit(ElectricInductanceUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ElectricInductanceUnit.Henry: return _value; - case ElectricInductanceUnit.Microhenry: return (_value) * 1e-6d; - case ElectricInductanceUnit.Millihenry: return (_value) * 1e-3d; - case ElectricInductanceUnit.Nanohenry: return (_value) * 1e-9d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ElectricInductanceUnit.Henry => _value, + ElectricInductanceUnit.Microhenry => (_value) * 1e-6d, + ElectricInductanceUnit.Millihenry => (_value) * 1e-3d, + ElectricInductanceUnit.Nanohenry => (_value) * 1e-9d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ElectricInductanceUnit unit) @@ -185,15 +184,14 @@ private double GetValueAs(ElectricInductanceUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ElectricInductanceUnit.Henry: return baseUnitValue; - case ElectricInductanceUnit.Microhenry: return (baseUnitValue) / 1e-6d; - case ElectricInductanceUnit.Millihenry: return (baseUnitValue) / 1e-3d; - case ElectricInductanceUnit.Nanohenry: return (baseUnitValue) / 1e-9d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ElectricInductanceUnit.Henry => baseUnitValue, + ElectricInductanceUnit.Microhenry => (baseUnitValue) / 1e-6d, + ElectricInductanceUnit.Millihenry => (baseUnitValue) / 1e-3d, + ElectricInductanceUnit.Nanohenry => (baseUnitValue) / 1e-9d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotential.g.cs index 4382d4e83f..1e6024b4c6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -175,16 +175,15 @@ public ElectricPotential ToUnit(ElectricPotentialUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ElectricPotentialUnit.Kilovolt: return (_value) * 1e3d; - case ElectricPotentialUnit.Megavolt: return (_value) * 1e6d; - case ElectricPotentialUnit.Microvolt: return (_value) * 1e-6d; - case ElectricPotentialUnit.Millivolt: return (_value) * 1e-3d; - case ElectricPotentialUnit.Volt: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ElectricPotentialUnit.Kilovolt => (_value) * 1e3d, + ElectricPotentialUnit.Megavolt => (_value) * 1e6d, + ElectricPotentialUnit.Microvolt => (_value) * 1e-6d, + ElectricPotentialUnit.Millivolt => (_value) * 1e-3d, + ElectricPotentialUnit.Volt => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ElectricPotentialUnit unit) @@ -194,16 +193,15 @@ private double GetValueAs(ElectricPotentialUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ElectricPotentialUnit.Kilovolt: return (baseUnitValue) / 1e3d; - case ElectricPotentialUnit.Megavolt: return (baseUnitValue) / 1e6d; - case ElectricPotentialUnit.Microvolt: return (baseUnitValue) / 1e-6d; - case ElectricPotentialUnit.Millivolt: return (baseUnitValue) / 1e-3d; - case ElectricPotentialUnit.Volt: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ElectricPotentialUnit.Kilovolt => (baseUnitValue) / 1e3d, + ElectricPotentialUnit.Megavolt => (baseUnitValue) / 1e6d, + ElectricPotentialUnit.Microvolt => (baseUnitValue) / 1e-6d, + ElectricPotentialUnit.Millivolt => (baseUnitValue) / 1e-3d, + ElectricPotentialUnit.Volt => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index 79af150776..67d0fc50d2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -175,16 +175,15 @@ public ElectricPotentialAc ToUnit(ElectricPotentialAcUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ElectricPotentialAcUnit.KilovoltAc: return (_value) * 1e3d; - case ElectricPotentialAcUnit.MegavoltAc: return (_value) * 1e6d; - case ElectricPotentialAcUnit.MicrovoltAc: return (_value) * 1e-6d; - case ElectricPotentialAcUnit.MillivoltAc: return (_value) * 1e-3d; - case ElectricPotentialAcUnit.VoltAc: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ElectricPotentialAcUnit.KilovoltAc => (_value) * 1e3d, + ElectricPotentialAcUnit.MegavoltAc => (_value) * 1e6d, + ElectricPotentialAcUnit.MicrovoltAc => (_value) * 1e-6d, + ElectricPotentialAcUnit.MillivoltAc => (_value) * 1e-3d, + ElectricPotentialAcUnit.VoltAc => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ElectricPotentialAcUnit unit) @@ -194,16 +193,15 @@ private double GetValueAs(ElectricPotentialAcUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ElectricPotentialAcUnit.KilovoltAc: return (baseUnitValue) / 1e3d; - case ElectricPotentialAcUnit.MegavoltAc: return (baseUnitValue) / 1e6d; - case ElectricPotentialAcUnit.MicrovoltAc: return (baseUnitValue) / 1e-6d; - case ElectricPotentialAcUnit.MillivoltAc: return (baseUnitValue) / 1e-3d; - case ElectricPotentialAcUnit.VoltAc: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ElectricPotentialAcUnit.KilovoltAc => (baseUnitValue) / 1e3d, + ElectricPotentialAcUnit.MegavoltAc => (baseUnitValue) / 1e6d, + ElectricPotentialAcUnit.MicrovoltAc => (baseUnitValue) / 1e-6d, + ElectricPotentialAcUnit.MillivoltAc => (baseUnitValue) / 1e-3d, + ElectricPotentialAcUnit.VoltAc => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index 64851e98b2..a37e2a91dc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -340,31 +340,30 @@ public ElectricPotentialChangeRate ToUnit(ElectricPotentialChangeRateUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ElectricPotentialChangeRateUnit.KilovoltPerHour: return (_value/3600) * 1e3d; - case ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond: return (_value*1E6) * 1e3d; - case ElectricPotentialChangeRateUnit.KilovoltPerMinute: return (_value/60) * 1e3d; - case ElectricPotentialChangeRateUnit.KilovoltPerSecond: return (_value) * 1e3d; - case ElectricPotentialChangeRateUnit.MegavoltPerHour: return (_value/3600) * 1e6d; - case ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond: return (_value*1E6) * 1e6d; - case ElectricPotentialChangeRateUnit.MegavoltPerMinute: return (_value/60) * 1e6d; - case ElectricPotentialChangeRateUnit.MegavoltPerSecond: return (_value) * 1e6d; - case ElectricPotentialChangeRateUnit.MicrovoltPerHour: return (_value/3600) * 1e-6d; - case ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond: return (_value*1E6) * 1e-6d; - case ElectricPotentialChangeRateUnit.MicrovoltPerMinute: return (_value/60) * 1e-6d; - case ElectricPotentialChangeRateUnit.MicrovoltPerSecond: return (_value) * 1e-6d; - case ElectricPotentialChangeRateUnit.MillivoltPerHour: return (_value/3600) * 1e-3d; - case ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond: return (_value*1E6) * 1e-3d; - case ElectricPotentialChangeRateUnit.MillivoltPerMinute: return (_value/60) * 1e-3d; - case ElectricPotentialChangeRateUnit.MillivoltPerSecond: return (_value) * 1e-3d; - case ElectricPotentialChangeRateUnit.VoltPerHour: return _value/3600; - case ElectricPotentialChangeRateUnit.VoltPerMicrosecond: return _value*1E6; - case ElectricPotentialChangeRateUnit.VoltPerMinute: return _value/60; - case ElectricPotentialChangeRateUnit.VoltPerSecond: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ElectricPotentialChangeRateUnit.KilovoltPerHour => (_value/3600) * 1e3d, + ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond => (_value*1E6) * 1e3d, + ElectricPotentialChangeRateUnit.KilovoltPerMinute => (_value/60) * 1e3d, + ElectricPotentialChangeRateUnit.KilovoltPerSecond => (_value) * 1e3d, + ElectricPotentialChangeRateUnit.MegavoltPerHour => (_value/3600) * 1e6d, + ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond => (_value*1E6) * 1e6d, + ElectricPotentialChangeRateUnit.MegavoltPerMinute => (_value/60) * 1e6d, + ElectricPotentialChangeRateUnit.MegavoltPerSecond => (_value) * 1e6d, + ElectricPotentialChangeRateUnit.MicrovoltPerHour => (_value/3600) * 1e-6d, + ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond => (_value*1E6) * 1e-6d, + ElectricPotentialChangeRateUnit.MicrovoltPerMinute => (_value/60) * 1e-6d, + ElectricPotentialChangeRateUnit.MicrovoltPerSecond => (_value) * 1e-6d, + ElectricPotentialChangeRateUnit.MillivoltPerHour => (_value/3600) * 1e-3d, + ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond => (_value*1E6) * 1e-3d, + ElectricPotentialChangeRateUnit.MillivoltPerMinute => (_value/60) * 1e-3d, + ElectricPotentialChangeRateUnit.MillivoltPerSecond => (_value) * 1e-3d, + ElectricPotentialChangeRateUnit.VoltPerHour => _value/3600, + ElectricPotentialChangeRateUnit.VoltPerMicrosecond => _value*1E6, + ElectricPotentialChangeRateUnit.VoltPerMinute => _value/60, + ElectricPotentialChangeRateUnit.VoltPerSecond => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ElectricPotentialChangeRateUnit unit) @@ -374,31 +373,30 @@ private double GetValueAs(ElectricPotentialChangeRateUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ElectricPotentialChangeRateUnit.KilovoltPerHour: return (baseUnitValue*3600) / 1e3d; - case ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond: return (baseUnitValue/1E6) / 1e3d; - case ElectricPotentialChangeRateUnit.KilovoltPerMinute: return (baseUnitValue*60) / 1e3d; - case ElectricPotentialChangeRateUnit.KilovoltPerSecond: return (baseUnitValue) / 1e3d; - case ElectricPotentialChangeRateUnit.MegavoltPerHour: return (baseUnitValue*3600) / 1e6d; - case ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond: return (baseUnitValue/1E6) / 1e6d; - case ElectricPotentialChangeRateUnit.MegavoltPerMinute: return (baseUnitValue*60) / 1e6d; - case ElectricPotentialChangeRateUnit.MegavoltPerSecond: return (baseUnitValue) / 1e6d; - case ElectricPotentialChangeRateUnit.MicrovoltPerHour: return (baseUnitValue*3600) / 1e-6d; - case ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond: return (baseUnitValue/1E6) / 1e-6d; - case ElectricPotentialChangeRateUnit.MicrovoltPerMinute: return (baseUnitValue*60) / 1e-6d; - case ElectricPotentialChangeRateUnit.MicrovoltPerSecond: return (baseUnitValue) / 1e-6d; - case ElectricPotentialChangeRateUnit.MillivoltPerHour: return (baseUnitValue*3600) / 1e-3d; - case ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond: return (baseUnitValue/1E6) / 1e-3d; - case ElectricPotentialChangeRateUnit.MillivoltPerMinute: return (baseUnitValue*60) / 1e-3d; - case ElectricPotentialChangeRateUnit.MillivoltPerSecond: return (baseUnitValue) / 1e-3d; - case ElectricPotentialChangeRateUnit.VoltPerHour: return baseUnitValue*3600; - case ElectricPotentialChangeRateUnit.VoltPerMicrosecond: return baseUnitValue/1E6; - case ElectricPotentialChangeRateUnit.VoltPerMinute: return baseUnitValue*60; - case ElectricPotentialChangeRateUnit.VoltPerSecond: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ElectricPotentialChangeRateUnit.KilovoltPerHour => (baseUnitValue*3600) / 1e3d, + ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond => (baseUnitValue/1E6) / 1e3d, + ElectricPotentialChangeRateUnit.KilovoltPerMinute => (baseUnitValue*60) / 1e3d, + ElectricPotentialChangeRateUnit.KilovoltPerSecond => (baseUnitValue) / 1e3d, + ElectricPotentialChangeRateUnit.MegavoltPerHour => (baseUnitValue*3600) / 1e6d, + ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond => (baseUnitValue/1E6) / 1e6d, + ElectricPotentialChangeRateUnit.MegavoltPerMinute => (baseUnitValue*60) / 1e6d, + ElectricPotentialChangeRateUnit.MegavoltPerSecond => (baseUnitValue) / 1e6d, + ElectricPotentialChangeRateUnit.MicrovoltPerHour => (baseUnitValue*3600) / 1e-6d, + ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond => (baseUnitValue/1E6) / 1e-6d, + ElectricPotentialChangeRateUnit.MicrovoltPerMinute => (baseUnitValue*60) / 1e-6d, + ElectricPotentialChangeRateUnit.MicrovoltPerSecond => (baseUnitValue) / 1e-6d, + ElectricPotentialChangeRateUnit.MillivoltPerHour => (baseUnitValue*3600) / 1e-3d, + ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond => (baseUnitValue/1E6) / 1e-3d, + ElectricPotentialChangeRateUnit.MillivoltPerMinute => (baseUnitValue*60) / 1e-3d, + ElectricPotentialChangeRateUnit.MillivoltPerSecond => (baseUnitValue) / 1e-3d, + ElectricPotentialChangeRateUnit.VoltPerHour => baseUnitValue*3600, + ElectricPotentialChangeRateUnit.VoltPerMicrosecond => baseUnitValue/1E6, + ElectricPotentialChangeRateUnit.VoltPerMinute => baseUnitValue*60, + ElectricPotentialChangeRateUnit.VoltPerSecond => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index e0c291d885..c8f51687f2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -175,16 +175,15 @@ public ElectricPotentialDc ToUnit(ElectricPotentialDcUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ElectricPotentialDcUnit.KilovoltDc: return (_value) * 1e3d; - case ElectricPotentialDcUnit.MegavoltDc: return (_value) * 1e6d; - case ElectricPotentialDcUnit.MicrovoltDc: return (_value) * 1e-6d; - case ElectricPotentialDcUnit.MillivoltDc: return (_value) * 1e-3d; - case ElectricPotentialDcUnit.VoltDc: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ElectricPotentialDcUnit.KilovoltDc => (_value) * 1e3d, + ElectricPotentialDcUnit.MegavoltDc => (_value) * 1e6d, + ElectricPotentialDcUnit.MicrovoltDc => (_value) * 1e-6d, + ElectricPotentialDcUnit.MillivoltDc => (_value) * 1e-3d, + ElectricPotentialDcUnit.VoltDc => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ElectricPotentialDcUnit unit) @@ -194,16 +193,15 @@ private double GetValueAs(ElectricPotentialDcUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ElectricPotentialDcUnit.KilovoltDc: return (baseUnitValue) / 1e3d; - case ElectricPotentialDcUnit.MegavoltDc: return (baseUnitValue) / 1e6d; - case ElectricPotentialDcUnit.MicrovoltDc: return (baseUnitValue) / 1e-6d; - case ElectricPotentialDcUnit.MillivoltDc: return (baseUnitValue) / 1e-3d; - case ElectricPotentialDcUnit.VoltDc: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ElectricPotentialDcUnit.KilovoltDc => (baseUnitValue) / 1e3d, + ElectricPotentialDcUnit.MegavoltDc => (baseUnitValue) / 1e6d, + ElectricPotentialDcUnit.MicrovoltDc => (baseUnitValue) / 1e-6d, + ElectricPotentialDcUnit.MillivoltDc => (baseUnitValue) / 1e-3d, + ElectricPotentialDcUnit.VoltDc => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistance.g.cs index b81be57112..449e272490 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -186,17 +186,16 @@ public ElectricResistance ToUnit(ElectricResistanceUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ElectricResistanceUnit.Gigaohm: return (_value) * 1e9d; - case ElectricResistanceUnit.Kiloohm: return (_value) * 1e3d; - case ElectricResistanceUnit.Megaohm: return (_value) * 1e6d; - case ElectricResistanceUnit.Microohm: return (_value) * 1e-6d; - case ElectricResistanceUnit.Milliohm: return (_value) * 1e-3d; - case ElectricResistanceUnit.Ohm: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ElectricResistanceUnit.Gigaohm => (_value) * 1e9d, + ElectricResistanceUnit.Kiloohm => (_value) * 1e3d, + ElectricResistanceUnit.Megaohm => (_value) * 1e6d, + ElectricResistanceUnit.Microohm => (_value) * 1e-6d, + ElectricResistanceUnit.Milliohm => (_value) * 1e-3d, + ElectricResistanceUnit.Ohm => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ElectricResistanceUnit unit) @@ -206,17 +205,16 @@ private double GetValueAs(ElectricResistanceUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ElectricResistanceUnit.Gigaohm: return (baseUnitValue) / 1e9d; - case ElectricResistanceUnit.Kiloohm: return (baseUnitValue) / 1e3d; - case ElectricResistanceUnit.Megaohm: return (baseUnitValue) / 1e6d; - case ElectricResistanceUnit.Microohm: return (baseUnitValue) / 1e-6d; - case ElectricResistanceUnit.Milliohm: return (baseUnitValue) / 1e-3d; - case ElectricResistanceUnit.Ohm: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ElectricResistanceUnit.Gigaohm => (baseUnitValue) / 1e9d, + ElectricResistanceUnit.Kiloohm => (baseUnitValue) / 1e3d, + ElectricResistanceUnit.Megaohm => (baseUnitValue) / 1e6d, + ElectricResistanceUnit.Microohm => (baseUnitValue) / 1e-6d, + ElectricResistanceUnit.Milliohm => (baseUnitValue) / 1e-3d, + ElectricResistanceUnit.Ohm => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistivity.g.cs index e7dd622b3a..9c9e42aaa6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -277,25 +277,24 @@ public ElectricResistivity ToUnit(ElectricResistivityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ElectricResistivityUnit.KiloohmCentimeter: return (_value/100) * 1e3d; - case ElectricResistivityUnit.KiloohmMeter: return (_value) * 1e3d; - case ElectricResistivityUnit.MegaohmCentimeter: return (_value/100) * 1e6d; - case ElectricResistivityUnit.MegaohmMeter: return (_value) * 1e6d; - case ElectricResistivityUnit.MicroohmCentimeter: return (_value/100) * 1e-6d; - case ElectricResistivityUnit.MicroohmMeter: return (_value) * 1e-6d; - case ElectricResistivityUnit.MilliohmCentimeter: return (_value/100) * 1e-3d; - case ElectricResistivityUnit.MilliohmMeter: return (_value) * 1e-3d; - case ElectricResistivityUnit.NanoohmCentimeter: return (_value/100) * 1e-9d; - case ElectricResistivityUnit.NanoohmMeter: return (_value) * 1e-9d; - case ElectricResistivityUnit.OhmCentimeter: return _value/100; - case ElectricResistivityUnit.OhmMeter: return _value; - case ElectricResistivityUnit.PicoohmCentimeter: return (_value/100) * 1e-12d; - case ElectricResistivityUnit.PicoohmMeter: return (_value) * 1e-12d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ElectricResistivityUnit.KiloohmCentimeter => (_value/100) * 1e3d, + ElectricResistivityUnit.KiloohmMeter => (_value) * 1e3d, + ElectricResistivityUnit.MegaohmCentimeter => (_value/100) * 1e6d, + ElectricResistivityUnit.MegaohmMeter => (_value) * 1e6d, + ElectricResistivityUnit.MicroohmCentimeter => (_value/100) * 1e-6d, + ElectricResistivityUnit.MicroohmMeter => (_value) * 1e-6d, + ElectricResistivityUnit.MilliohmCentimeter => (_value/100) * 1e-3d, + ElectricResistivityUnit.MilliohmMeter => (_value) * 1e-3d, + ElectricResistivityUnit.NanoohmCentimeter => (_value/100) * 1e-9d, + ElectricResistivityUnit.NanoohmMeter => (_value) * 1e-9d, + ElectricResistivityUnit.OhmCentimeter => _value/100, + ElectricResistivityUnit.OhmMeter => _value, + ElectricResistivityUnit.PicoohmCentimeter => (_value/100) * 1e-12d, + ElectricResistivityUnit.PicoohmMeter => (_value) * 1e-12d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ElectricResistivityUnit unit) @@ -305,25 +304,24 @@ private double GetValueAs(ElectricResistivityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ElectricResistivityUnit.KiloohmCentimeter: return (baseUnitValue*100) / 1e3d; - case ElectricResistivityUnit.KiloohmMeter: return (baseUnitValue) / 1e3d; - case ElectricResistivityUnit.MegaohmCentimeter: return (baseUnitValue*100) / 1e6d; - case ElectricResistivityUnit.MegaohmMeter: return (baseUnitValue) / 1e6d; - case ElectricResistivityUnit.MicroohmCentimeter: return (baseUnitValue*100) / 1e-6d; - case ElectricResistivityUnit.MicroohmMeter: return (baseUnitValue) / 1e-6d; - case ElectricResistivityUnit.MilliohmCentimeter: return (baseUnitValue*100) / 1e-3d; - case ElectricResistivityUnit.MilliohmMeter: return (baseUnitValue) / 1e-3d; - case ElectricResistivityUnit.NanoohmCentimeter: return (baseUnitValue*100) / 1e-9d; - case ElectricResistivityUnit.NanoohmMeter: return (baseUnitValue) / 1e-9d; - case ElectricResistivityUnit.OhmCentimeter: return baseUnitValue*100; - case ElectricResistivityUnit.OhmMeter: return baseUnitValue; - case ElectricResistivityUnit.PicoohmCentimeter: return (baseUnitValue*100) / 1e-12d; - case ElectricResistivityUnit.PicoohmMeter: return (baseUnitValue) / 1e-12d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ElectricResistivityUnit.KiloohmCentimeter => (baseUnitValue*100) / 1e3d, + ElectricResistivityUnit.KiloohmMeter => (baseUnitValue) / 1e3d, + ElectricResistivityUnit.MegaohmCentimeter => (baseUnitValue*100) / 1e6d, + ElectricResistivityUnit.MegaohmMeter => (baseUnitValue) / 1e6d, + ElectricResistivityUnit.MicroohmCentimeter => (baseUnitValue*100) / 1e-6d, + ElectricResistivityUnit.MicroohmMeter => (baseUnitValue) / 1e-6d, + ElectricResistivityUnit.MilliohmCentimeter => (baseUnitValue*100) / 1e-3d, + ElectricResistivityUnit.MilliohmMeter => (baseUnitValue) / 1e-3d, + ElectricResistivityUnit.NanoohmCentimeter => (baseUnitValue*100) / 1e-9d, + ElectricResistivityUnit.NanoohmMeter => (baseUnitValue) / 1e-9d, + ElectricResistivityUnit.OhmCentimeter => baseUnitValue*100, + ElectricResistivityUnit.OhmMeter => baseUnitValue, + ElectricResistivityUnit.PicoohmCentimeter => (baseUnitValue*100) / 1e-12d, + ElectricResistivityUnit.PicoohmMeter => (baseUnitValue) / 1e-12d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index e5fb9bcf49..1fa3d07ef0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -156,14 +156,13 @@ public ElectricSurfaceChargeDensity ToUnit(ElectricSurfaceChargeDensityUnit unit /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter: return _value * 1.0e4; - case ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch: return _value * 1.5500031000062000e3; - case ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter => _value * 1.0e4, + ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch => _value * 1.5500031000062000e3, + ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ElectricSurfaceChargeDensityUnit unit) @@ -173,14 +172,13 @@ private double GetValueAs(ElectricSurfaceChargeDensityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter: return baseUnitValue / 1.0e4; - case ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch: return baseUnitValue / 1.5500031000062000e3; - case ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter => baseUnitValue / 1.0e4, + ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch => baseUnitValue / 1.5500031000062000e3, + ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Energy.g.cs index ddc221eec5..fe24a39b99 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Energy.g.cs @@ -516,47 +516,46 @@ public Energy ToUnit(EnergyUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case EnergyUnit.BritishThermalUnit: return _value*1055.05585262; - case EnergyUnit.Calorie: return _value*4.184; - case EnergyUnit.DecathermEc: return (_value*1.05505585262e8) * 1e1d; - case EnergyUnit.DecathermImperial: return (_value*1.05505585257348e8) * 1e1d; - case EnergyUnit.DecathermUs: return (_value*1.054804e8) * 1e1d; - case EnergyUnit.ElectronVolt: return _value*1.602176565e-19; - case EnergyUnit.Erg: return _value*1e-7; - case EnergyUnit.FootPound: return _value*1.355817948; - case EnergyUnit.GigabritishThermalUnit: return (_value*1055.05585262) * 1e9d; - case EnergyUnit.GigaelectronVolt: return (_value*1.602176565e-19) * 1e9d; - case EnergyUnit.Gigajoule: return (_value) * 1e9d; - case EnergyUnit.GigawattDay: return (_value*24*3600d) * 1e9d; - case EnergyUnit.GigawattHour: return (_value*3600d) * 1e9d; - case EnergyUnit.HorsepowerHour: return _value*2.6845195377e6; - case EnergyUnit.Joule: return _value; - case EnergyUnit.KilobritishThermalUnit: return (_value*1055.05585262) * 1e3d; - case EnergyUnit.Kilocalorie: return (_value*4.184) * 1e3d; - case EnergyUnit.KiloelectronVolt: return (_value*1.602176565e-19) * 1e3d; - case EnergyUnit.Kilojoule: return (_value) * 1e3d; - case EnergyUnit.KilowattDay: return (_value*24*3600d) * 1e3d; - case EnergyUnit.KilowattHour: return (_value*3600d) * 1e3d; - case EnergyUnit.MegabritishThermalUnit: return (_value*1055.05585262) * 1e6d; - case EnergyUnit.Megacalorie: return (_value*4.184) * 1e6d; - case EnergyUnit.MegaelectronVolt: return (_value*1.602176565e-19) * 1e6d; - case EnergyUnit.Megajoule: return (_value) * 1e6d; - case EnergyUnit.MegawattDay: return (_value*24*3600d) * 1e6d; - case EnergyUnit.MegawattHour: return (_value*3600d) * 1e6d; - case EnergyUnit.Millijoule: return (_value) * 1e-3d; - case EnergyUnit.TeraelectronVolt: return (_value*1.602176565e-19) * 1e12d; - case EnergyUnit.TerawattDay: return (_value*24*3600d) * 1e12d; - case EnergyUnit.TerawattHour: return (_value*3600d) * 1e12d; - case EnergyUnit.ThermEc: return _value*1.05505585262e8; - case EnergyUnit.ThermImperial: return _value*1.05505585257348e8; - case EnergyUnit.ThermUs: return _value*1.054804e8; - case EnergyUnit.WattDay: return _value*24*3600d; - case EnergyUnit.WattHour: return _value*3600d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + EnergyUnit.BritishThermalUnit => _value*1055.05585262, + EnergyUnit.Calorie => _value*4.184, + EnergyUnit.DecathermEc => (_value*1.05505585262e8) * 1e1d, + EnergyUnit.DecathermImperial => (_value*1.05505585257348e8) * 1e1d, + EnergyUnit.DecathermUs => (_value*1.054804e8) * 1e1d, + EnergyUnit.ElectronVolt => _value*1.602176565e-19, + EnergyUnit.Erg => _value*1e-7, + EnergyUnit.FootPound => _value*1.355817948, + EnergyUnit.GigabritishThermalUnit => (_value*1055.05585262) * 1e9d, + EnergyUnit.GigaelectronVolt => (_value*1.602176565e-19) * 1e9d, + EnergyUnit.Gigajoule => (_value) * 1e9d, + EnergyUnit.GigawattDay => (_value*24*3600d) * 1e9d, + EnergyUnit.GigawattHour => (_value*3600d) * 1e9d, + EnergyUnit.HorsepowerHour => _value*2.6845195377e6, + EnergyUnit.Joule => _value, + EnergyUnit.KilobritishThermalUnit => (_value*1055.05585262) * 1e3d, + EnergyUnit.Kilocalorie => (_value*4.184) * 1e3d, + EnergyUnit.KiloelectronVolt => (_value*1.602176565e-19) * 1e3d, + EnergyUnit.Kilojoule => (_value) * 1e3d, + EnergyUnit.KilowattDay => (_value*24*3600d) * 1e3d, + EnergyUnit.KilowattHour => (_value*3600d) * 1e3d, + EnergyUnit.MegabritishThermalUnit => (_value*1055.05585262) * 1e6d, + EnergyUnit.Megacalorie => (_value*4.184) * 1e6d, + EnergyUnit.MegaelectronVolt => (_value*1.602176565e-19) * 1e6d, + EnergyUnit.Megajoule => (_value) * 1e6d, + EnergyUnit.MegawattDay => (_value*24*3600d) * 1e6d, + EnergyUnit.MegawattHour => (_value*3600d) * 1e6d, + EnergyUnit.Millijoule => (_value) * 1e-3d, + EnergyUnit.TeraelectronVolt => (_value*1.602176565e-19) * 1e12d, + EnergyUnit.TerawattDay => (_value*24*3600d) * 1e12d, + EnergyUnit.TerawattHour => (_value*3600d) * 1e12d, + EnergyUnit.ThermEc => _value*1.05505585262e8, + EnergyUnit.ThermImperial => _value*1.05505585257348e8, + EnergyUnit.ThermUs => _value*1.054804e8, + EnergyUnit.WattDay => _value*24*3600d, + EnergyUnit.WattHour => _value*3600d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(EnergyUnit unit) @@ -566,47 +565,46 @@ private double GetValueAs(EnergyUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case EnergyUnit.BritishThermalUnit: return baseUnitValue/1055.05585262; - case EnergyUnit.Calorie: return baseUnitValue/4.184; - case EnergyUnit.DecathermEc: return (baseUnitValue/1.05505585262e8) / 1e1d; - case EnergyUnit.DecathermImperial: return (baseUnitValue/1.05505585257348e8) / 1e1d; - case EnergyUnit.DecathermUs: return (baseUnitValue/1.054804e8) / 1e1d; - case EnergyUnit.ElectronVolt: return baseUnitValue/1.602176565e-19; - case EnergyUnit.Erg: return baseUnitValue/1e-7; - case EnergyUnit.FootPound: return baseUnitValue/1.355817948; - case EnergyUnit.GigabritishThermalUnit: return (baseUnitValue/1055.05585262) / 1e9d; - case EnergyUnit.GigaelectronVolt: return (baseUnitValue/1.602176565e-19) / 1e9d; - case EnergyUnit.Gigajoule: return (baseUnitValue) / 1e9d; - case EnergyUnit.GigawattDay: return (baseUnitValue/(24*3600d)) / 1e9d; - case EnergyUnit.GigawattHour: return (baseUnitValue/3600d) / 1e9d; - case EnergyUnit.HorsepowerHour: return baseUnitValue/2.6845195377e6; - case EnergyUnit.Joule: return baseUnitValue; - case EnergyUnit.KilobritishThermalUnit: return (baseUnitValue/1055.05585262) / 1e3d; - case EnergyUnit.Kilocalorie: return (baseUnitValue/4.184) / 1e3d; - case EnergyUnit.KiloelectronVolt: return (baseUnitValue/1.602176565e-19) / 1e3d; - case EnergyUnit.Kilojoule: return (baseUnitValue) / 1e3d; - case EnergyUnit.KilowattDay: return (baseUnitValue/(24*3600d)) / 1e3d; - case EnergyUnit.KilowattHour: return (baseUnitValue/3600d) / 1e3d; - case EnergyUnit.MegabritishThermalUnit: return (baseUnitValue/1055.05585262) / 1e6d; - case EnergyUnit.Megacalorie: return (baseUnitValue/4.184) / 1e6d; - case EnergyUnit.MegaelectronVolt: return (baseUnitValue/1.602176565e-19) / 1e6d; - case EnergyUnit.Megajoule: return (baseUnitValue) / 1e6d; - case EnergyUnit.MegawattDay: return (baseUnitValue/(24*3600d)) / 1e6d; - case EnergyUnit.MegawattHour: return (baseUnitValue/3600d) / 1e6d; - case EnergyUnit.Millijoule: return (baseUnitValue) / 1e-3d; - case EnergyUnit.TeraelectronVolt: return (baseUnitValue/1.602176565e-19) / 1e12d; - case EnergyUnit.TerawattDay: return (baseUnitValue/(24*3600d)) / 1e12d; - case EnergyUnit.TerawattHour: return (baseUnitValue/3600d) / 1e12d; - case EnergyUnit.ThermEc: return baseUnitValue/1.05505585262e8; - case EnergyUnit.ThermImperial: return baseUnitValue/1.05505585257348e8; - case EnergyUnit.ThermUs: return baseUnitValue/1.054804e8; - case EnergyUnit.WattDay: return baseUnitValue/(24*3600d); - case EnergyUnit.WattHour: return baseUnitValue/3600d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + EnergyUnit.BritishThermalUnit => baseUnitValue/1055.05585262, + EnergyUnit.Calorie => baseUnitValue/4.184, + EnergyUnit.DecathermEc => (baseUnitValue/1.05505585262e8) / 1e1d, + EnergyUnit.DecathermImperial => (baseUnitValue/1.05505585257348e8) / 1e1d, + EnergyUnit.DecathermUs => (baseUnitValue/1.054804e8) / 1e1d, + EnergyUnit.ElectronVolt => baseUnitValue/1.602176565e-19, + EnergyUnit.Erg => baseUnitValue/1e-7, + EnergyUnit.FootPound => baseUnitValue/1.355817948, + EnergyUnit.GigabritishThermalUnit => (baseUnitValue/1055.05585262) / 1e9d, + EnergyUnit.GigaelectronVolt => (baseUnitValue/1.602176565e-19) / 1e9d, + EnergyUnit.Gigajoule => (baseUnitValue) / 1e9d, + EnergyUnit.GigawattDay => (baseUnitValue/(24*3600d)) / 1e9d, + EnergyUnit.GigawattHour => (baseUnitValue/3600d) / 1e9d, + EnergyUnit.HorsepowerHour => baseUnitValue/2.6845195377e6, + EnergyUnit.Joule => baseUnitValue, + EnergyUnit.KilobritishThermalUnit => (baseUnitValue/1055.05585262) / 1e3d, + EnergyUnit.Kilocalorie => (baseUnitValue/4.184) / 1e3d, + EnergyUnit.KiloelectronVolt => (baseUnitValue/1.602176565e-19) / 1e3d, + EnergyUnit.Kilojoule => (baseUnitValue) / 1e3d, + EnergyUnit.KilowattDay => (baseUnitValue/(24*3600d)) / 1e3d, + EnergyUnit.KilowattHour => (baseUnitValue/3600d) / 1e3d, + EnergyUnit.MegabritishThermalUnit => (baseUnitValue/1055.05585262) / 1e6d, + EnergyUnit.Megacalorie => (baseUnitValue/4.184) / 1e6d, + EnergyUnit.MegaelectronVolt => (baseUnitValue/1.602176565e-19) / 1e6d, + EnergyUnit.Megajoule => (baseUnitValue) / 1e6d, + EnergyUnit.MegawattDay => (baseUnitValue/(24*3600d)) / 1e6d, + EnergyUnit.MegawattHour => (baseUnitValue/3600d) / 1e6d, + EnergyUnit.Millijoule => (baseUnitValue) / 1e-3d, + EnergyUnit.TeraelectronVolt => (baseUnitValue/1.602176565e-19) / 1e12d, + EnergyUnit.TerawattDay => (baseUnitValue/(24*3600d)) / 1e12d, + EnergyUnit.TerawattHour => (baseUnitValue/3600d) / 1e12d, + EnergyUnit.ThermEc => baseUnitValue/1.05505585262e8, + EnergyUnit.ThermImperial => baseUnitValue/1.05505585257348e8, + EnergyUnit.ThermUs => baseUnitValue/1.054804e8, + EnergyUnit.WattDay => baseUnitValue/(24*3600d), + EnergyUnit.WattHour => baseUnitValue/3600d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Entropy.g.cs index 6ef8a8e3ac..1cc38dc07c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Entropy.g.cs @@ -197,18 +197,17 @@ public Entropy ToUnit(EntropyUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case EntropyUnit.CaloriePerKelvin: return _value*4.184; - case EntropyUnit.JoulePerDegreeCelsius: return _value; - case EntropyUnit.JoulePerKelvin: return _value; - case EntropyUnit.KilocaloriePerKelvin: return (_value*4.184) * 1e3d; - case EntropyUnit.KilojoulePerDegreeCelsius: return (_value) * 1e3d; - case EntropyUnit.KilojoulePerKelvin: return (_value) * 1e3d; - case EntropyUnit.MegajoulePerKelvin: return (_value) * 1e6d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + EntropyUnit.CaloriePerKelvin => _value*4.184, + EntropyUnit.JoulePerDegreeCelsius => _value, + EntropyUnit.JoulePerKelvin => _value, + EntropyUnit.KilocaloriePerKelvin => (_value*4.184) * 1e3d, + EntropyUnit.KilojoulePerDegreeCelsius => (_value) * 1e3d, + EntropyUnit.KilojoulePerKelvin => (_value) * 1e3d, + EntropyUnit.MegajoulePerKelvin => (_value) * 1e6d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(EntropyUnit unit) @@ -218,18 +217,17 @@ private double GetValueAs(EntropyUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case EntropyUnit.CaloriePerKelvin: return baseUnitValue/4.184; - case EntropyUnit.JoulePerDegreeCelsius: return baseUnitValue; - case EntropyUnit.JoulePerKelvin: return baseUnitValue; - case EntropyUnit.KilocaloriePerKelvin: return (baseUnitValue/4.184) / 1e3d; - case EntropyUnit.KilojoulePerDegreeCelsius: return (baseUnitValue) / 1e3d; - case EntropyUnit.KilojoulePerKelvin: return (baseUnitValue) / 1e3d; - case EntropyUnit.MegajoulePerKelvin: return (baseUnitValue) / 1e6d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + EntropyUnit.CaloriePerKelvin => baseUnitValue/4.184, + EntropyUnit.JoulePerDegreeCelsius => baseUnitValue, + EntropyUnit.JoulePerKelvin => baseUnitValue, + EntropyUnit.KilocaloriePerKelvin => (baseUnitValue/4.184) / 1e3d, + EntropyUnit.KilojoulePerDegreeCelsius => (baseUnitValue) / 1e3d, + EntropyUnit.KilojoulePerKelvin => (baseUnitValue) / 1e3d, + EntropyUnit.MegajoulePerKelvin => (baseUnitValue) / 1e6d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Force.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Force.g.cs index 716e2617ea..68ac1a9dbf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Force.g.cs @@ -285,26 +285,25 @@ public Force ToUnit(ForceUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ForceUnit.Decanewton: return (_value) * 1e1d; - case ForceUnit.Dyn: return _value/1e5; - case ForceUnit.KilogramForce: return _value*9.80665002864; - case ForceUnit.Kilonewton: return (_value) * 1e3d; - case ForceUnit.KiloPond: return _value*9.80665002864; - case ForceUnit.KilopoundForce: return (_value*4.4482216152605095551842641431421) * 1e3d; - case ForceUnit.Meganewton: return (_value) * 1e6d; - case ForceUnit.Micronewton: return (_value) * 1e-6d; - case ForceUnit.Millinewton: return (_value) * 1e-3d; - case ForceUnit.Newton: return _value; - case ForceUnit.OunceForce: return _value*2.780138509537812e-1; - case ForceUnit.Poundal: return _value*0.13825502798973041652092282466083; - case ForceUnit.PoundForce: return _value*4.4482216152605095551842641431421; - case ForceUnit.ShortTonForce: return _value*8.896443230521e3; - case ForceUnit.TonneForce: return _value*9.80665002864e3; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ForceUnit.Decanewton => (_value) * 1e1d, + ForceUnit.Dyn => _value/1e5, + ForceUnit.KilogramForce => _value*9.80665002864, + ForceUnit.Kilonewton => (_value) * 1e3d, + ForceUnit.KiloPond => _value*9.80665002864, + ForceUnit.KilopoundForce => (_value*4.4482216152605095551842641431421) * 1e3d, + ForceUnit.Meganewton => (_value) * 1e6d, + ForceUnit.Micronewton => (_value) * 1e-6d, + ForceUnit.Millinewton => (_value) * 1e-3d, + ForceUnit.Newton => _value, + ForceUnit.OunceForce => _value*2.780138509537812e-1, + ForceUnit.Poundal => _value*0.13825502798973041652092282466083, + ForceUnit.PoundForce => _value*4.4482216152605095551842641431421, + ForceUnit.ShortTonForce => _value*8.896443230521e3, + ForceUnit.TonneForce => _value*9.80665002864e3, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ForceUnit unit) @@ -314,26 +313,25 @@ private double GetValueAs(ForceUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ForceUnit.Decanewton: return (baseUnitValue) / 1e1d; - case ForceUnit.Dyn: return baseUnitValue*1e5; - case ForceUnit.KilogramForce: return baseUnitValue/9.80665002864; - case ForceUnit.Kilonewton: return (baseUnitValue) / 1e3d; - case ForceUnit.KiloPond: return baseUnitValue/9.80665002864; - case ForceUnit.KilopoundForce: return (baseUnitValue/4.4482216152605095551842641431421) / 1e3d; - case ForceUnit.Meganewton: return (baseUnitValue) / 1e6d; - case ForceUnit.Micronewton: return (baseUnitValue) / 1e-6d; - case ForceUnit.Millinewton: return (baseUnitValue) / 1e-3d; - case ForceUnit.Newton: return baseUnitValue; - case ForceUnit.OunceForce: return baseUnitValue/2.780138509537812e-1; - case ForceUnit.Poundal: return baseUnitValue/0.13825502798973041652092282466083; - case ForceUnit.PoundForce: return baseUnitValue/4.4482216152605095551842641431421; - case ForceUnit.ShortTonForce: return baseUnitValue/8.896443230521e3; - case ForceUnit.TonneForce: return baseUnitValue/9.80665002864e3; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ForceUnit.Decanewton => (baseUnitValue) / 1e1d, + ForceUnit.Dyn => baseUnitValue*1e5, + ForceUnit.KilogramForce => baseUnitValue/9.80665002864, + ForceUnit.Kilonewton => (baseUnitValue) / 1e3d, + ForceUnit.KiloPond => baseUnitValue/9.80665002864, + ForceUnit.KilopoundForce => (baseUnitValue/4.4482216152605095551842641431421) / 1e3d, + ForceUnit.Meganewton => (baseUnitValue) / 1e6d, + ForceUnit.Micronewton => (baseUnitValue) / 1e-6d, + ForceUnit.Millinewton => (baseUnitValue) / 1e-3d, + ForceUnit.Newton => baseUnitValue, + ForceUnit.OunceForce => baseUnitValue/2.780138509537812e-1, + ForceUnit.Poundal => baseUnitValue/0.13825502798973041652092282466083, + ForceUnit.PoundForce => baseUnitValue/4.4482216152605095551842641431421, + ForceUnit.ShortTonForce => baseUnitValue/8.896443230521e3, + ForceUnit.TonneForce => baseUnitValue/9.80665002864e3, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs index dc1a6cb002..8bf1fff97c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -285,26 +285,25 @@ public ForceChangeRate ToUnit(ForceChangeRateUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ForceChangeRateUnit.CentinewtonPerSecond: return (_value) * 1e-2d; - case ForceChangeRateUnit.DecanewtonPerMinute: return (_value/60) * 1e1d; - case ForceChangeRateUnit.DecanewtonPerSecond: return (_value) * 1e1d; - case ForceChangeRateUnit.DecinewtonPerSecond: return (_value) * 1e-1d; - case ForceChangeRateUnit.KilonewtonPerMinute: return (_value/60) * 1e3d; - case ForceChangeRateUnit.KilonewtonPerSecond: return (_value) * 1e3d; - case ForceChangeRateUnit.KilopoundForcePerMinute: return (_value*4.4482216152605095551842641431421/60) * 1e3d; - case ForceChangeRateUnit.KilopoundForcePerSecond: return (_value*4.4482216152605095551842641431421) * 1e3d; - case ForceChangeRateUnit.MicronewtonPerSecond: return (_value) * 1e-6d; - case ForceChangeRateUnit.MillinewtonPerSecond: return (_value) * 1e-3d; - case ForceChangeRateUnit.NanonewtonPerSecond: return (_value) * 1e-9d; - case ForceChangeRateUnit.NewtonPerMinute: return _value/60; - case ForceChangeRateUnit.NewtonPerSecond: return _value; - case ForceChangeRateUnit.PoundForcePerMinute: return _value*4.4482216152605095551842641431421/60; - case ForceChangeRateUnit.PoundForcePerSecond: return _value*4.4482216152605095551842641431421; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ForceChangeRateUnit.CentinewtonPerSecond => (_value) * 1e-2d, + ForceChangeRateUnit.DecanewtonPerMinute => (_value/60) * 1e1d, + ForceChangeRateUnit.DecanewtonPerSecond => (_value) * 1e1d, + ForceChangeRateUnit.DecinewtonPerSecond => (_value) * 1e-1d, + ForceChangeRateUnit.KilonewtonPerMinute => (_value/60) * 1e3d, + ForceChangeRateUnit.KilonewtonPerSecond => (_value) * 1e3d, + ForceChangeRateUnit.KilopoundForcePerMinute => (_value*4.4482216152605095551842641431421/60) * 1e3d, + ForceChangeRateUnit.KilopoundForcePerSecond => (_value*4.4482216152605095551842641431421) * 1e3d, + ForceChangeRateUnit.MicronewtonPerSecond => (_value) * 1e-6d, + ForceChangeRateUnit.MillinewtonPerSecond => (_value) * 1e-3d, + ForceChangeRateUnit.NanonewtonPerSecond => (_value) * 1e-9d, + ForceChangeRateUnit.NewtonPerMinute => _value/60, + ForceChangeRateUnit.NewtonPerSecond => _value, + ForceChangeRateUnit.PoundForcePerMinute => _value*4.4482216152605095551842641431421/60, + ForceChangeRateUnit.PoundForcePerSecond => _value*4.4482216152605095551842641431421, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ForceChangeRateUnit unit) @@ -314,26 +313,25 @@ private double GetValueAs(ForceChangeRateUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ForceChangeRateUnit.CentinewtonPerSecond: return (baseUnitValue) / 1e-2d; - case ForceChangeRateUnit.DecanewtonPerMinute: return (baseUnitValue*60) / 1e1d; - case ForceChangeRateUnit.DecanewtonPerSecond: return (baseUnitValue) / 1e1d; - case ForceChangeRateUnit.DecinewtonPerSecond: return (baseUnitValue) / 1e-1d; - case ForceChangeRateUnit.KilonewtonPerMinute: return (baseUnitValue*60) / 1e3d; - case ForceChangeRateUnit.KilonewtonPerSecond: return (baseUnitValue) / 1e3d; - case ForceChangeRateUnit.KilopoundForcePerMinute: return (baseUnitValue/4.4482216152605095551842641431421*60) / 1e3d; - case ForceChangeRateUnit.KilopoundForcePerSecond: return (baseUnitValue/4.4482216152605095551842641431421) / 1e3d; - case ForceChangeRateUnit.MicronewtonPerSecond: return (baseUnitValue) / 1e-6d; - case ForceChangeRateUnit.MillinewtonPerSecond: return (baseUnitValue) / 1e-3d; - case ForceChangeRateUnit.NanonewtonPerSecond: return (baseUnitValue) / 1e-9d; - case ForceChangeRateUnit.NewtonPerMinute: return baseUnitValue*60; - case ForceChangeRateUnit.NewtonPerSecond: return baseUnitValue; - case ForceChangeRateUnit.PoundForcePerMinute: return baseUnitValue/4.4482216152605095551842641431421*60; - case ForceChangeRateUnit.PoundForcePerSecond: return baseUnitValue/4.4482216152605095551842641431421; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ForceChangeRateUnit.CentinewtonPerSecond => (baseUnitValue) / 1e-2d, + ForceChangeRateUnit.DecanewtonPerMinute => (baseUnitValue*60) / 1e1d, + ForceChangeRateUnit.DecanewtonPerSecond => (baseUnitValue) / 1e1d, + ForceChangeRateUnit.DecinewtonPerSecond => (baseUnitValue) / 1e-1d, + ForceChangeRateUnit.KilonewtonPerMinute => (baseUnitValue*60) / 1e3d, + ForceChangeRateUnit.KilonewtonPerSecond => (baseUnitValue) / 1e3d, + ForceChangeRateUnit.KilopoundForcePerMinute => (baseUnitValue/4.4482216152605095551842641431421*60) / 1e3d, + ForceChangeRateUnit.KilopoundForcePerSecond => (baseUnitValue/4.4482216152605095551842641431421) / 1e3d, + ForceChangeRateUnit.MicronewtonPerSecond => (baseUnitValue) / 1e-6d, + ForceChangeRateUnit.MillinewtonPerSecond => (baseUnitValue) / 1e-3d, + ForceChangeRateUnit.NanonewtonPerSecond => (baseUnitValue) / 1e-9d, + ForceChangeRateUnit.NewtonPerMinute => baseUnitValue*60, + ForceChangeRateUnit.NewtonPerSecond => baseUnitValue, + ForceChangeRateUnit.PoundForcePerMinute => baseUnitValue/4.4482216152605095551842641431421*60, + ForceChangeRateUnit.PoundForcePerSecond => baseUnitValue/4.4482216152605095551842641431421, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForcePerLength.g.cs index 3616342038..760f0fb292 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -538,49 +538,48 @@ public ForcePerLength ToUnit(ForcePerLengthUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ForcePerLengthUnit.CentinewtonPerCentimeter: return (_value*1e2) * 1e-2d; - case ForcePerLengthUnit.CentinewtonPerMeter: return (_value) * 1e-2d; - case ForcePerLengthUnit.CentinewtonPerMillimeter: return (_value*1e3) * 1e-2d; - case ForcePerLengthUnit.DecanewtonPerCentimeter: return (_value*1e2) * 1e1d; - case ForcePerLengthUnit.DecanewtonPerMeter: return (_value) * 1e1d; - case ForcePerLengthUnit.DecanewtonPerMillimeter: return (_value*1e3) * 1e1d; - case ForcePerLengthUnit.DecinewtonPerCentimeter: return (_value*1e2) * 1e-1d; - case ForcePerLengthUnit.DecinewtonPerMeter: return (_value) * 1e-1d; - case ForcePerLengthUnit.DecinewtonPerMillimeter: return (_value*1e3) * 1e-1d; - case ForcePerLengthUnit.KilogramForcePerCentimeter: return _value*980.665002864; - case ForcePerLengthUnit.KilogramForcePerMeter: return _value*9.80665002864; - case ForcePerLengthUnit.KilogramForcePerMillimeter: return _value*9.80665002864e3; - case ForcePerLengthUnit.KilonewtonPerCentimeter: return (_value*1e2) * 1e3d; - case ForcePerLengthUnit.KilonewtonPerMeter: return (_value) * 1e3d; - case ForcePerLengthUnit.KilonewtonPerMillimeter: return (_value*1e3) * 1e3d; - case ForcePerLengthUnit.KilopoundForcePerFoot: return _value*14593.90292; - case ForcePerLengthUnit.KilopoundForcePerInch: return _value*1.75126835e5; - case ForcePerLengthUnit.MeganewtonPerCentimeter: return (_value*1e2) * 1e6d; - case ForcePerLengthUnit.MeganewtonPerMeter: return (_value) * 1e6d; - case ForcePerLengthUnit.MeganewtonPerMillimeter: return (_value*1e3) * 1e6d; - case ForcePerLengthUnit.MicronewtonPerCentimeter: return (_value*1e2) * 1e-6d; - case ForcePerLengthUnit.MicronewtonPerMeter: return (_value) * 1e-6d; - case ForcePerLengthUnit.MicronewtonPerMillimeter: return (_value*1e3) * 1e-6d; - case ForcePerLengthUnit.MillinewtonPerCentimeter: return (_value*1e2) * 1e-3d; - case ForcePerLengthUnit.MillinewtonPerMeter: return (_value) * 1e-3d; - case ForcePerLengthUnit.MillinewtonPerMillimeter: return (_value*1e3) * 1e-3d; - case ForcePerLengthUnit.NanonewtonPerCentimeter: return (_value*1e2) * 1e-9d; - case ForcePerLengthUnit.NanonewtonPerMeter: return (_value) * 1e-9d; - case ForcePerLengthUnit.NanonewtonPerMillimeter: return (_value*1e3) * 1e-9d; - case ForcePerLengthUnit.NewtonPerCentimeter: return _value*1e2; - case ForcePerLengthUnit.NewtonPerMeter: return _value; - case ForcePerLengthUnit.NewtonPerMillimeter: return _value*1e3; - case ForcePerLengthUnit.PoundForcePerFoot: return _value*14.59390292; - case ForcePerLengthUnit.PoundForcePerInch: return _value*1.75126835e2; - case ForcePerLengthUnit.PoundForcePerYard: return _value*4.864634307; - case ForcePerLengthUnit.TonneForcePerCentimeter: return _value*9.80665002864e5; - case ForcePerLengthUnit.TonneForcePerMeter: return _value*9.80665002864e3; - case ForcePerLengthUnit.TonneForcePerMillimeter: return _value*9.80665002864e6; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ForcePerLengthUnit.CentinewtonPerCentimeter => (_value*1e2) * 1e-2d, + ForcePerLengthUnit.CentinewtonPerMeter => (_value) * 1e-2d, + ForcePerLengthUnit.CentinewtonPerMillimeter => (_value*1e3) * 1e-2d, + ForcePerLengthUnit.DecanewtonPerCentimeter => (_value*1e2) * 1e1d, + ForcePerLengthUnit.DecanewtonPerMeter => (_value) * 1e1d, + ForcePerLengthUnit.DecanewtonPerMillimeter => (_value*1e3) * 1e1d, + ForcePerLengthUnit.DecinewtonPerCentimeter => (_value*1e2) * 1e-1d, + ForcePerLengthUnit.DecinewtonPerMeter => (_value) * 1e-1d, + ForcePerLengthUnit.DecinewtonPerMillimeter => (_value*1e3) * 1e-1d, + ForcePerLengthUnit.KilogramForcePerCentimeter => _value*980.665002864, + ForcePerLengthUnit.KilogramForcePerMeter => _value*9.80665002864, + ForcePerLengthUnit.KilogramForcePerMillimeter => _value*9.80665002864e3, + ForcePerLengthUnit.KilonewtonPerCentimeter => (_value*1e2) * 1e3d, + ForcePerLengthUnit.KilonewtonPerMeter => (_value) * 1e3d, + ForcePerLengthUnit.KilonewtonPerMillimeter => (_value*1e3) * 1e3d, + ForcePerLengthUnit.KilopoundForcePerFoot => _value*14593.90292, + ForcePerLengthUnit.KilopoundForcePerInch => _value*1.75126835e5, + ForcePerLengthUnit.MeganewtonPerCentimeter => (_value*1e2) * 1e6d, + ForcePerLengthUnit.MeganewtonPerMeter => (_value) * 1e6d, + ForcePerLengthUnit.MeganewtonPerMillimeter => (_value*1e3) * 1e6d, + ForcePerLengthUnit.MicronewtonPerCentimeter => (_value*1e2) * 1e-6d, + ForcePerLengthUnit.MicronewtonPerMeter => (_value) * 1e-6d, + ForcePerLengthUnit.MicronewtonPerMillimeter => (_value*1e3) * 1e-6d, + ForcePerLengthUnit.MillinewtonPerCentimeter => (_value*1e2) * 1e-3d, + ForcePerLengthUnit.MillinewtonPerMeter => (_value) * 1e-3d, + ForcePerLengthUnit.MillinewtonPerMillimeter => (_value*1e3) * 1e-3d, + ForcePerLengthUnit.NanonewtonPerCentimeter => (_value*1e2) * 1e-9d, + ForcePerLengthUnit.NanonewtonPerMeter => (_value) * 1e-9d, + ForcePerLengthUnit.NanonewtonPerMillimeter => (_value*1e3) * 1e-9d, + ForcePerLengthUnit.NewtonPerCentimeter => _value*1e2, + ForcePerLengthUnit.NewtonPerMeter => _value, + ForcePerLengthUnit.NewtonPerMillimeter => _value*1e3, + ForcePerLengthUnit.PoundForcePerFoot => _value*14.59390292, + ForcePerLengthUnit.PoundForcePerInch => _value*1.75126835e2, + ForcePerLengthUnit.PoundForcePerYard => _value*4.864634307, + ForcePerLengthUnit.TonneForcePerCentimeter => _value*9.80665002864e5, + ForcePerLengthUnit.TonneForcePerMeter => _value*9.80665002864e3, + ForcePerLengthUnit.TonneForcePerMillimeter => _value*9.80665002864e6, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ForcePerLengthUnit unit) @@ -590,49 +589,48 @@ private double GetValueAs(ForcePerLengthUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ForcePerLengthUnit.CentinewtonPerCentimeter: return (baseUnitValue/1e2) / 1e-2d; - case ForcePerLengthUnit.CentinewtonPerMeter: return (baseUnitValue) / 1e-2d; - case ForcePerLengthUnit.CentinewtonPerMillimeter: return (baseUnitValue/1e3) / 1e-2d; - case ForcePerLengthUnit.DecanewtonPerCentimeter: return (baseUnitValue/1e2) / 1e1d; - case ForcePerLengthUnit.DecanewtonPerMeter: return (baseUnitValue) / 1e1d; - case ForcePerLengthUnit.DecanewtonPerMillimeter: return (baseUnitValue/1e3) / 1e1d; - case ForcePerLengthUnit.DecinewtonPerCentimeter: return (baseUnitValue/1e2) / 1e-1d; - case ForcePerLengthUnit.DecinewtonPerMeter: return (baseUnitValue) / 1e-1d; - case ForcePerLengthUnit.DecinewtonPerMillimeter: return (baseUnitValue/1e3) / 1e-1d; - case ForcePerLengthUnit.KilogramForcePerCentimeter: return baseUnitValue/980.665002864; - case ForcePerLengthUnit.KilogramForcePerMeter: return baseUnitValue/9.80665002864; - case ForcePerLengthUnit.KilogramForcePerMillimeter: return baseUnitValue/9.80665002864e3; - case ForcePerLengthUnit.KilonewtonPerCentimeter: return (baseUnitValue/1e2) / 1e3d; - case ForcePerLengthUnit.KilonewtonPerMeter: return (baseUnitValue) / 1e3d; - case ForcePerLengthUnit.KilonewtonPerMillimeter: return (baseUnitValue/1e3) / 1e3d; - case ForcePerLengthUnit.KilopoundForcePerFoot: return baseUnitValue/14593.90292; - case ForcePerLengthUnit.KilopoundForcePerInch: return baseUnitValue/1.75126835e5; - case ForcePerLengthUnit.MeganewtonPerCentimeter: return (baseUnitValue/1e2) / 1e6d; - case ForcePerLengthUnit.MeganewtonPerMeter: return (baseUnitValue) / 1e6d; - case ForcePerLengthUnit.MeganewtonPerMillimeter: return (baseUnitValue/1e3) / 1e6d; - case ForcePerLengthUnit.MicronewtonPerCentimeter: return (baseUnitValue/1e2) / 1e-6d; - case ForcePerLengthUnit.MicronewtonPerMeter: return (baseUnitValue) / 1e-6d; - case ForcePerLengthUnit.MicronewtonPerMillimeter: return (baseUnitValue/1e3) / 1e-6d; - case ForcePerLengthUnit.MillinewtonPerCentimeter: return (baseUnitValue/1e2) / 1e-3d; - case ForcePerLengthUnit.MillinewtonPerMeter: return (baseUnitValue) / 1e-3d; - case ForcePerLengthUnit.MillinewtonPerMillimeter: return (baseUnitValue/1e3) / 1e-3d; - case ForcePerLengthUnit.NanonewtonPerCentimeter: return (baseUnitValue/1e2) / 1e-9d; - case ForcePerLengthUnit.NanonewtonPerMeter: return (baseUnitValue) / 1e-9d; - case ForcePerLengthUnit.NanonewtonPerMillimeter: return (baseUnitValue/1e3) / 1e-9d; - case ForcePerLengthUnit.NewtonPerCentimeter: return baseUnitValue/1e2; - case ForcePerLengthUnit.NewtonPerMeter: return baseUnitValue; - case ForcePerLengthUnit.NewtonPerMillimeter: return baseUnitValue/1e3; - case ForcePerLengthUnit.PoundForcePerFoot: return baseUnitValue/14.59390292; - case ForcePerLengthUnit.PoundForcePerInch: return baseUnitValue/1.75126835e2; - case ForcePerLengthUnit.PoundForcePerYard: return baseUnitValue/4.864634307; - case ForcePerLengthUnit.TonneForcePerCentimeter: return baseUnitValue/9.80665002864e5; - case ForcePerLengthUnit.TonneForcePerMeter: return baseUnitValue/9.80665002864e3; - case ForcePerLengthUnit.TonneForcePerMillimeter: return baseUnitValue/9.80665002864e6; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ForcePerLengthUnit.CentinewtonPerCentimeter => (baseUnitValue/1e2) / 1e-2d, + ForcePerLengthUnit.CentinewtonPerMeter => (baseUnitValue) / 1e-2d, + ForcePerLengthUnit.CentinewtonPerMillimeter => (baseUnitValue/1e3) / 1e-2d, + ForcePerLengthUnit.DecanewtonPerCentimeter => (baseUnitValue/1e2) / 1e1d, + ForcePerLengthUnit.DecanewtonPerMeter => (baseUnitValue) / 1e1d, + ForcePerLengthUnit.DecanewtonPerMillimeter => (baseUnitValue/1e3) / 1e1d, + ForcePerLengthUnit.DecinewtonPerCentimeter => (baseUnitValue/1e2) / 1e-1d, + ForcePerLengthUnit.DecinewtonPerMeter => (baseUnitValue) / 1e-1d, + ForcePerLengthUnit.DecinewtonPerMillimeter => (baseUnitValue/1e3) / 1e-1d, + ForcePerLengthUnit.KilogramForcePerCentimeter => baseUnitValue/980.665002864, + ForcePerLengthUnit.KilogramForcePerMeter => baseUnitValue/9.80665002864, + ForcePerLengthUnit.KilogramForcePerMillimeter => baseUnitValue/9.80665002864e3, + ForcePerLengthUnit.KilonewtonPerCentimeter => (baseUnitValue/1e2) / 1e3d, + ForcePerLengthUnit.KilonewtonPerMeter => (baseUnitValue) / 1e3d, + ForcePerLengthUnit.KilonewtonPerMillimeter => (baseUnitValue/1e3) / 1e3d, + ForcePerLengthUnit.KilopoundForcePerFoot => baseUnitValue/14593.90292, + ForcePerLengthUnit.KilopoundForcePerInch => baseUnitValue/1.75126835e5, + ForcePerLengthUnit.MeganewtonPerCentimeter => (baseUnitValue/1e2) / 1e6d, + ForcePerLengthUnit.MeganewtonPerMeter => (baseUnitValue) / 1e6d, + ForcePerLengthUnit.MeganewtonPerMillimeter => (baseUnitValue/1e3) / 1e6d, + ForcePerLengthUnit.MicronewtonPerCentimeter => (baseUnitValue/1e2) / 1e-6d, + ForcePerLengthUnit.MicronewtonPerMeter => (baseUnitValue) / 1e-6d, + ForcePerLengthUnit.MicronewtonPerMillimeter => (baseUnitValue/1e3) / 1e-6d, + ForcePerLengthUnit.MillinewtonPerCentimeter => (baseUnitValue/1e2) / 1e-3d, + ForcePerLengthUnit.MillinewtonPerMeter => (baseUnitValue) / 1e-3d, + ForcePerLengthUnit.MillinewtonPerMillimeter => (baseUnitValue/1e3) / 1e-3d, + ForcePerLengthUnit.NanonewtonPerCentimeter => (baseUnitValue/1e2) / 1e-9d, + ForcePerLengthUnit.NanonewtonPerMeter => (baseUnitValue) / 1e-9d, + ForcePerLengthUnit.NanonewtonPerMillimeter => (baseUnitValue/1e3) / 1e-9d, + ForcePerLengthUnit.NewtonPerCentimeter => baseUnitValue/1e2, + ForcePerLengthUnit.NewtonPerMeter => baseUnitValue, + ForcePerLengthUnit.NewtonPerMillimeter => baseUnitValue/1e3, + ForcePerLengthUnit.PoundForcePerFoot => baseUnitValue/14.59390292, + ForcePerLengthUnit.PoundForcePerInch => baseUnitValue/1.75126835e2, + ForcePerLengthUnit.PoundForcePerYard => baseUnitValue/4.864634307, + ForcePerLengthUnit.TonneForcePerCentimeter => baseUnitValue/9.80665002864e5, + ForcePerLengthUnit.TonneForcePerMeter => baseUnitValue/9.80665002864e3, + ForcePerLengthUnit.TonneForcePerMillimeter => baseUnitValue/9.80665002864e6, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs index d0bb679fdc..d8d1d30a4e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs @@ -241,22 +241,21 @@ public Frequency ToUnit(FrequencyUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case FrequencyUnit.BeatPerMinute: return _value/60; - case FrequencyUnit.BUnit: return Math.Sqrt(_value * 1e3); - case FrequencyUnit.CyclePerHour: return _value/3600; - case FrequencyUnit.CyclePerMinute: return _value/60; - case FrequencyUnit.Gigahertz: return (_value) * 1e9d; - case FrequencyUnit.Hertz: return _value; - case FrequencyUnit.Kilohertz: return (_value) * 1e3d; - case FrequencyUnit.Megahertz: return (_value) * 1e6d; - case FrequencyUnit.PerSecond: return _value; - case FrequencyUnit.RadianPerSecond: return _value/6.2831853072; - case FrequencyUnit.Terahertz: return (_value) * 1e12d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + FrequencyUnit.BeatPerMinute => _value/60, + FrequencyUnit.BUnit => Math.Sqrt(_value * 1e3), + FrequencyUnit.CyclePerHour => _value/3600, + FrequencyUnit.CyclePerMinute => _value/60, + FrequencyUnit.Gigahertz => (_value) * 1e9d, + FrequencyUnit.Hertz => _value, + FrequencyUnit.Kilohertz => (_value) * 1e3d, + FrequencyUnit.Megahertz => (_value) * 1e6d, + FrequencyUnit.PerSecond => _value, + FrequencyUnit.RadianPerSecond => _value/6.2831853072, + FrequencyUnit.Terahertz => (_value) * 1e12d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(FrequencyUnit unit) @@ -266,22 +265,21 @@ private double GetValueAs(FrequencyUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case FrequencyUnit.BeatPerMinute: return baseUnitValue*60; - case FrequencyUnit.BUnit: return baseUnitValue * baseUnitValue * 1e-3; - case FrequencyUnit.CyclePerHour: return baseUnitValue*3600; - case FrequencyUnit.CyclePerMinute: return baseUnitValue*60; - case FrequencyUnit.Gigahertz: return (baseUnitValue) / 1e9d; - case FrequencyUnit.Hertz: return baseUnitValue; - case FrequencyUnit.Kilohertz: return (baseUnitValue) / 1e3d; - case FrequencyUnit.Megahertz: return (baseUnitValue) / 1e6d; - case FrequencyUnit.PerSecond: return baseUnitValue; - case FrequencyUnit.RadianPerSecond: return baseUnitValue*6.2831853072; - case FrequencyUnit.Terahertz: return (baseUnitValue) / 1e12d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + FrequencyUnit.BeatPerMinute => baseUnitValue*60, + FrequencyUnit.BUnit => baseUnitValue * baseUnitValue * 1e-3, + FrequencyUnit.CyclePerHour => baseUnitValue*3600, + FrequencyUnit.CyclePerMinute => baseUnitValue*60, + FrequencyUnit.Gigahertz => (baseUnitValue) / 1e9d, + FrequencyUnit.Hertz => baseUnitValue, + FrequencyUnit.Kilohertz => (baseUnitValue) / 1e3d, + FrequencyUnit.Megahertz => (baseUnitValue) / 1e6d, + FrequencyUnit.PerSecond => baseUnitValue, + FrequencyUnit.RadianPerSecond => baseUnitValue*6.2831853072, + FrequencyUnit.Terahertz => (baseUnitValue) / 1e12d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/FuelEfficiency.g.cs index c737175658..8bbba45fb9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -167,15 +167,14 @@ public FuelEfficiency ToUnit(FuelEfficiencyUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case FuelEfficiencyUnit.KilometerPerLiter: return 100/_value; - case FuelEfficiencyUnit.LiterPer100Kilometers: return _value; - case FuelEfficiencyUnit.MilePerUkGallon: return (100*4.54609188)/(1.609344*_value); - case FuelEfficiencyUnit.MilePerUsGallon: return (100*3.785411784)/(1.609344*_value); - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + FuelEfficiencyUnit.KilometerPerLiter => 100/_value, + FuelEfficiencyUnit.LiterPer100Kilometers => _value, + FuelEfficiencyUnit.MilePerUkGallon => (100*4.54609188)/(1.609344*_value), + FuelEfficiencyUnit.MilePerUsGallon => (100*3.785411784)/(1.609344*_value), + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(FuelEfficiencyUnit unit) @@ -185,15 +184,14 @@ private double GetValueAs(FuelEfficiencyUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case FuelEfficiencyUnit.KilometerPerLiter: return 100/baseUnitValue; - case FuelEfficiencyUnit.LiterPer100Kilometers: return baseUnitValue; - case FuelEfficiencyUnit.MilePerUkGallon: return (100*4.54609188)/(1.609344*baseUnitValue); - case FuelEfficiencyUnit.MilePerUsGallon: return (100*3.785411784)/(1.609344*baseUnitValue); - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + FuelEfficiencyUnit.KilometerPerLiter => 100/baseUnitValue, + FuelEfficiencyUnit.LiterPer100Kilometers => baseUnitValue, + FuelEfficiencyUnit.MilePerUkGallon => (100*4.54609188)/(1.609344*baseUnitValue), + FuelEfficiencyUnit.MilePerUsGallon => (100*3.785411784)/(1.609344*baseUnitValue), + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatFlux.g.cs index c6e1975ea4..366593d530 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatFlux.g.cs @@ -318,29 +318,28 @@ public HeatFlux ToUnit(HeatFluxUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case HeatFluxUnit.BtuPerHourSquareFoot: return _value*3.15459075; - case HeatFluxUnit.BtuPerMinuteSquareFoot: return _value*1.89275445e2; - case HeatFluxUnit.BtuPerSecondSquareFoot: return _value*1.13565267e4; - case HeatFluxUnit.BtuPerSecondSquareInch: return _value*1.63533984e6; - case HeatFluxUnit.CaloriePerSecondSquareCentimeter: return _value*4.1868e4; - case HeatFluxUnit.CentiwattPerSquareMeter: return (_value) * 1e-2d; - case HeatFluxUnit.DeciwattPerSquareMeter: return (_value) * 1e-1d; - case HeatFluxUnit.KilocaloriePerHourSquareMeter: return _value*1.163; - case HeatFluxUnit.KilocaloriePerSecondSquareCentimeter: return (_value*4.1868e4) * 1e3d; - case HeatFluxUnit.KilowattPerSquareMeter: return (_value) * 1e3d; - case HeatFluxUnit.MicrowattPerSquareMeter: return (_value) * 1e-6d; - case HeatFluxUnit.MilliwattPerSquareMeter: return (_value) * 1e-3d; - case HeatFluxUnit.NanowattPerSquareMeter: return (_value) * 1e-9d; - case HeatFluxUnit.PoundForcePerFootSecond: return _value*1.459390293720636e1; - case HeatFluxUnit.PoundPerSecondCubed: return _value*4.5359237e-1; - case HeatFluxUnit.WattPerSquareFoot: return _value*1.07639e1; - case HeatFluxUnit.WattPerSquareInch: return _value*1.5500031e3; - case HeatFluxUnit.WattPerSquareMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + HeatFluxUnit.BtuPerHourSquareFoot => _value*3.15459075, + HeatFluxUnit.BtuPerMinuteSquareFoot => _value*1.89275445e2, + HeatFluxUnit.BtuPerSecondSquareFoot => _value*1.13565267e4, + HeatFluxUnit.BtuPerSecondSquareInch => _value*1.63533984e6, + HeatFluxUnit.CaloriePerSecondSquareCentimeter => _value*4.1868e4, + HeatFluxUnit.CentiwattPerSquareMeter => (_value) * 1e-2d, + HeatFluxUnit.DeciwattPerSquareMeter => (_value) * 1e-1d, + HeatFluxUnit.KilocaloriePerHourSquareMeter => _value*1.163, + HeatFluxUnit.KilocaloriePerSecondSquareCentimeter => (_value*4.1868e4) * 1e3d, + HeatFluxUnit.KilowattPerSquareMeter => (_value) * 1e3d, + HeatFluxUnit.MicrowattPerSquareMeter => (_value) * 1e-6d, + HeatFluxUnit.MilliwattPerSquareMeter => (_value) * 1e-3d, + HeatFluxUnit.NanowattPerSquareMeter => (_value) * 1e-9d, + HeatFluxUnit.PoundForcePerFootSecond => _value*1.459390293720636e1, + HeatFluxUnit.PoundPerSecondCubed => _value*4.5359237e-1, + HeatFluxUnit.WattPerSquareFoot => _value*1.07639e1, + HeatFluxUnit.WattPerSquareInch => _value*1.5500031e3, + HeatFluxUnit.WattPerSquareMeter => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(HeatFluxUnit unit) @@ -350,29 +349,28 @@ private double GetValueAs(HeatFluxUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case HeatFluxUnit.BtuPerHourSquareFoot: return baseUnitValue/3.15459075; - case HeatFluxUnit.BtuPerMinuteSquareFoot: return baseUnitValue/1.89275445e2; - case HeatFluxUnit.BtuPerSecondSquareFoot: return baseUnitValue/1.13565267e4; - case HeatFluxUnit.BtuPerSecondSquareInch: return baseUnitValue/1.63533984e6; - case HeatFluxUnit.CaloriePerSecondSquareCentimeter: return baseUnitValue/4.1868e4; - case HeatFluxUnit.CentiwattPerSquareMeter: return (baseUnitValue) / 1e-2d; - case HeatFluxUnit.DeciwattPerSquareMeter: return (baseUnitValue) / 1e-1d; - case HeatFluxUnit.KilocaloriePerHourSquareMeter: return baseUnitValue/1.163; - case HeatFluxUnit.KilocaloriePerSecondSquareCentimeter: return (baseUnitValue/4.1868e4) / 1e3d; - case HeatFluxUnit.KilowattPerSquareMeter: return (baseUnitValue) / 1e3d; - case HeatFluxUnit.MicrowattPerSquareMeter: return (baseUnitValue) / 1e-6d; - case HeatFluxUnit.MilliwattPerSquareMeter: return (baseUnitValue) / 1e-3d; - case HeatFluxUnit.NanowattPerSquareMeter: return (baseUnitValue) / 1e-9d; - case HeatFluxUnit.PoundForcePerFootSecond: return baseUnitValue/1.459390293720636e1; - case HeatFluxUnit.PoundPerSecondCubed: return baseUnitValue/4.5359237e-1; - case HeatFluxUnit.WattPerSquareFoot: return baseUnitValue/1.07639e1; - case HeatFluxUnit.WattPerSquareInch: return baseUnitValue/1.5500031e3; - case HeatFluxUnit.WattPerSquareMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + HeatFluxUnit.BtuPerHourSquareFoot => baseUnitValue/3.15459075, + HeatFluxUnit.BtuPerMinuteSquareFoot => baseUnitValue/1.89275445e2, + HeatFluxUnit.BtuPerSecondSquareFoot => baseUnitValue/1.13565267e4, + HeatFluxUnit.BtuPerSecondSquareInch => baseUnitValue/1.63533984e6, + HeatFluxUnit.CaloriePerSecondSquareCentimeter => baseUnitValue/4.1868e4, + HeatFluxUnit.CentiwattPerSquareMeter => (baseUnitValue) / 1e-2d, + HeatFluxUnit.DeciwattPerSquareMeter => (baseUnitValue) / 1e-1d, + HeatFluxUnit.KilocaloriePerHourSquareMeter => baseUnitValue/1.163, + HeatFluxUnit.KilocaloriePerSecondSquareCentimeter => (baseUnitValue/4.1868e4) / 1e3d, + HeatFluxUnit.KilowattPerSquareMeter => (baseUnitValue) / 1e3d, + HeatFluxUnit.MicrowattPerSquareMeter => (baseUnitValue) / 1e-6d, + HeatFluxUnit.MilliwattPerSquareMeter => (baseUnitValue) / 1e-3d, + HeatFluxUnit.NanowattPerSquareMeter => (baseUnitValue) / 1e-9d, + HeatFluxUnit.PoundForcePerFootSecond => baseUnitValue/1.459390293720636e1, + HeatFluxUnit.PoundPerSecondCubed => baseUnitValue/4.5359237e-1, + HeatFluxUnit.WattPerSquareFoot => baseUnitValue/1.07639e1, + HeatFluxUnit.WattPerSquareInch => baseUnitValue/1.5500031e3, + HeatFluxUnit.WattPerSquareMeter => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 7c1be69980..239fe1dae5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -153,14 +153,13 @@ public HeatTransferCoefficient ToUnit(HeatTransferCoefficientUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit: return _value * 5.6782633411134878; - case HeatTransferCoefficientUnit.WattPerSquareMeterCelsius: return _value; - case HeatTransferCoefficientUnit.WattPerSquareMeterKelvin: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit => _value * 5.6782633411134878, + HeatTransferCoefficientUnit.WattPerSquareMeterCelsius => _value, + HeatTransferCoefficientUnit.WattPerSquareMeterKelvin => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(HeatTransferCoefficientUnit unit) @@ -170,14 +169,13 @@ private double GetValueAs(HeatTransferCoefficientUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit: return baseUnitValue / 5.6782633411134878; - case HeatTransferCoefficientUnit.WattPerSquareMeterCelsius: return baseUnitValue; - case HeatTransferCoefficientUnit.WattPerSquareMeterKelvin: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit => baseUnitValue / 5.6782633411134878, + HeatTransferCoefficientUnit.WattPerSquareMeterCelsius => baseUnitValue, + HeatTransferCoefficientUnit.WattPerSquareMeterKelvin => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Illuminance.g.cs index 9eb01b1992..0c2a753b15 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Illuminance.g.cs @@ -167,15 +167,14 @@ public Illuminance ToUnit(IlluminanceUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case IlluminanceUnit.Kilolux: return (_value) * 1e3d; - case IlluminanceUnit.Lux: return _value; - case IlluminanceUnit.Megalux: return (_value) * 1e6d; - case IlluminanceUnit.Millilux: return (_value) * 1e-3d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + IlluminanceUnit.Kilolux => (_value) * 1e3d, + IlluminanceUnit.Lux => _value, + IlluminanceUnit.Megalux => (_value) * 1e6d, + IlluminanceUnit.Millilux => (_value) * 1e-3d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(IlluminanceUnit unit) @@ -185,15 +184,14 @@ private double GetValueAs(IlluminanceUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case IlluminanceUnit.Kilolux: return (baseUnitValue) / 1e3d; - case IlluminanceUnit.Lux: return baseUnitValue; - case IlluminanceUnit.Megalux: return (baseUnitValue) / 1e6d; - case IlluminanceUnit.Millilux: return (baseUnitValue) / 1e-3d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + IlluminanceUnit.Kilolux => (baseUnitValue) / 1e3d, + IlluminanceUnit.Lux => baseUnitValue, + IlluminanceUnit.Megalux => (baseUnitValue) / 1e6d, + IlluminanceUnit.Millilux => (baseUnitValue) / 1e-3d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs index ae511027a1..725118fb25 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs @@ -406,37 +406,36 @@ public Information ToUnit(InformationUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case InformationUnit.Bit: return _value; - case InformationUnit.Byte: return _value*8d; - case InformationUnit.Exabit: return (_value) * 1e18d; - case InformationUnit.Exabyte: return (_value*8d) * 1e18d; - case InformationUnit.Exbibit: return (_value) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Exbibyte: return (_value*8d) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Gibibit: return (_value) * (1024d * 1024 * 1024); - case InformationUnit.Gibibyte: return (_value*8d) * (1024d * 1024 * 1024); - case InformationUnit.Gigabit: return (_value) * 1e9d; - case InformationUnit.Gigabyte: return (_value*8d) * 1e9d; - case InformationUnit.Kibibit: return (_value) * 1024d; - case InformationUnit.Kibibyte: return (_value*8d) * 1024d; - case InformationUnit.Kilobit: return (_value) * 1e3d; - case InformationUnit.Kilobyte: return (_value*8d) * 1e3d; - case InformationUnit.Mebibit: return (_value) * (1024d * 1024); - case InformationUnit.Mebibyte: return (_value*8d) * (1024d * 1024); - case InformationUnit.Megabit: return (_value) * 1e6d; - case InformationUnit.Megabyte: return (_value*8d) * 1e6d; - case InformationUnit.Pebibit: return (_value) * (1024d * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Pebibyte: return (_value*8d) * (1024d * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Petabit: return (_value) * 1e15d; - case InformationUnit.Petabyte: return (_value*8d) * 1e15d; - case InformationUnit.Tebibit: return (_value) * (1024d * 1024 * 1024 * 1024); - case InformationUnit.Tebibyte: return (_value*8d) * (1024d * 1024 * 1024 * 1024); - case InformationUnit.Terabit: return (_value) * 1e12d; - case InformationUnit.Terabyte: return (_value*8d) * 1e12d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + InformationUnit.Bit => _value, + InformationUnit.Byte => _value*8d, + InformationUnit.Exabit => (_value) * 1e18d, + InformationUnit.Exabyte => (_value*8d) * 1e18d, + InformationUnit.Exbibit => (_value) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024), + InformationUnit.Exbibyte => (_value*8d) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024), + InformationUnit.Gibibit => (_value) * (1024d * 1024 * 1024), + InformationUnit.Gibibyte => (_value*8d) * (1024d * 1024 * 1024), + InformationUnit.Gigabit => (_value) * 1e9d, + InformationUnit.Gigabyte => (_value*8d) * 1e9d, + InformationUnit.Kibibit => (_value) * 1024d, + InformationUnit.Kibibyte => (_value*8d) * 1024d, + InformationUnit.Kilobit => (_value) * 1e3d, + InformationUnit.Kilobyte => (_value*8d) * 1e3d, + InformationUnit.Mebibit => (_value) * (1024d * 1024), + InformationUnit.Mebibyte => (_value*8d) * (1024d * 1024), + InformationUnit.Megabit => (_value) * 1e6d, + InformationUnit.Megabyte => (_value*8d) * 1e6d, + InformationUnit.Pebibit => (_value) * (1024d * 1024 * 1024 * 1024 * 1024), + InformationUnit.Pebibyte => (_value*8d) * (1024d * 1024 * 1024 * 1024 * 1024), + InformationUnit.Petabit => (_value) * 1e15d, + InformationUnit.Petabyte => (_value*8d) * 1e15d, + InformationUnit.Tebibit => (_value) * (1024d * 1024 * 1024 * 1024), + InformationUnit.Tebibyte => (_value*8d) * (1024d * 1024 * 1024 * 1024), + InformationUnit.Terabit => (_value) * 1e12d, + InformationUnit.Terabyte => (_value*8d) * 1e12d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(InformationUnit unit) @@ -446,37 +445,36 @@ private double GetValueAs(InformationUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case InformationUnit.Bit: return baseUnitValue; - case InformationUnit.Byte: return baseUnitValue/8d; - case InformationUnit.Exabit: return (baseUnitValue) / 1e18d; - case InformationUnit.Exabyte: return (baseUnitValue/8d) / 1e18d; - case InformationUnit.Exbibit: return (baseUnitValue) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Exbibyte: return (baseUnitValue/8d) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Gibibit: return (baseUnitValue) / (1024d * 1024 * 1024); - case InformationUnit.Gibibyte: return (baseUnitValue/8d) / (1024d * 1024 * 1024); - case InformationUnit.Gigabit: return (baseUnitValue) / 1e9d; - case InformationUnit.Gigabyte: return (baseUnitValue/8d) / 1e9d; - case InformationUnit.Kibibit: return (baseUnitValue) / 1024d; - case InformationUnit.Kibibyte: return (baseUnitValue/8d) / 1024d; - case InformationUnit.Kilobit: return (baseUnitValue) / 1e3d; - case InformationUnit.Kilobyte: return (baseUnitValue/8d) / 1e3d; - case InformationUnit.Mebibit: return (baseUnitValue) / (1024d * 1024); - case InformationUnit.Mebibyte: return (baseUnitValue/8d) / (1024d * 1024); - case InformationUnit.Megabit: return (baseUnitValue) / 1e6d; - case InformationUnit.Megabyte: return (baseUnitValue/8d) / 1e6d; - case InformationUnit.Pebibit: return (baseUnitValue) / (1024d * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Pebibyte: return (baseUnitValue/8d) / (1024d * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Petabit: return (baseUnitValue) / 1e15d; - case InformationUnit.Petabyte: return (baseUnitValue/8d) / 1e15d; - case InformationUnit.Tebibit: return (baseUnitValue) / (1024d * 1024 * 1024 * 1024); - case InformationUnit.Tebibyte: return (baseUnitValue/8d) / (1024d * 1024 * 1024 * 1024); - case InformationUnit.Terabit: return (baseUnitValue) / 1e12d; - case InformationUnit.Terabyte: return (baseUnitValue/8d) / 1e12d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + InformationUnit.Bit => baseUnitValue, + InformationUnit.Byte => baseUnitValue/8d, + InformationUnit.Exabit => (baseUnitValue) / 1e18d, + InformationUnit.Exabyte => (baseUnitValue/8d) / 1e18d, + InformationUnit.Exbibit => (baseUnitValue) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024), + InformationUnit.Exbibyte => (baseUnitValue/8d) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024), + InformationUnit.Gibibit => (baseUnitValue) / (1024d * 1024 * 1024), + InformationUnit.Gibibyte => (baseUnitValue/8d) / (1024d * 1024 * 1024), + InformationUnit.Gigabit => (baseUnitValue) / 1e9d, + InformationUnit.Gigabyte => (baseUnitValue/8d) / 1e9d, + InformationUnit.Kibibit => (baseUnitValue) / 1024d, + InformationUnit.Kibibyte => (baseUnitValue/8d) / 1024d, + InformationUnit.Kilobit => (baseUnitValue) / 1e3d, + InformationUnit.Kilobyte => (baseUnitValue/8d) / 1e3d, + InformationUnit.Mebibit => (baseUnitValue) / (1024d * 1024), + InformationUnit.Mebibyte => (baseUnitValue/8d) / (1024d * 1024), + InformationUnit.Megabit => (baseUnitValue) / 1e6d, + InformationUnit.Megabyte => (baseUnitValue/8d) / 1e6d, + InformationUnit.Pebibit => (baseUnitValue) / (1024d * 1024 * 1024 * 1024 * 1024), + InformationUnit.Pebibyte => (baseUnitValue/8d) / (1024d * 1024 * 1024 * 1024 * 1024), + InformationUnit.Petabit => (baseUnitValue) / 1e15d, + InformationUnit.Petabyte => (baseUnitValue/8d) / 1e15d, + InformationUnit.Tebibit => (baseUnitValue) / (1024d * 1024 * 1024 * 1024), + InformationUnit.Tebibyte => (baseUnitValue/8d) / (1024d * 1024 * 1024 * 1024), + InformationUnit.Terabit => (baseUnitValue) / 1e12d, + InformationUnit.Terabyte => (baseUnitValue/8d) / 1e12d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiance.g.cs index 426d8359d3..95533fb3e4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiance.g.cs @@ -274,25 +274,24 @@ public Irradiance ToUnit(IrradianceUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case IrradianceUnit.KilowattPerSquareCentimeter: return (_value*10000) * 1e3d; - case IrradianceUnit.KilowattPerSquareMeter: return (_value) * 1e3d; - case IrradianceUnit.MegawattPerSquareCentimeter: return (_value*10000) * 1e6d; - case IrradianceUnit.MegawattPerSquareMeter: return (_value) * 1e6d; - case IrradianceUnit.MicrowattPerSquareCentimeter: return (_value*10000) * 1e-6d; - case IrradianceUnit.MicrowattPerSquareMeter: return (_value) * 1e-6d; - case IrradianceUnit.MilliwattPerSquareCentimeter: return (_value*10000) * 1e-3d; - case IrradianceUnit.MilliwattPerSquareMeter: return (_value) * 1e-3d; - case IrradianceUnit.NanowattPerSquareCentimeter: return (_value*10000) * 1e-9d; - case IrradianceUnit.NanowattPerSquareMeter: return (_value) * 1e-9d; - case IrradianceUnit.PicowattPerSquareCentimeter: return (_value*10000) * 1e-12d; - case IrradianceUnit.PicowattPerSquareMeter: return (_value) * 1e-12d; - case IrradianceUnit.WattPerSquareCentimeter: return _value*10000; - case IrradianceUnit.WattPerSquareMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + IrradianceUnit.KilowattPerSquareCentimeter => (_value*10000) * 1e3d, + IrradianceUnit.KilowattPerSquareMeter => (_value) * 1e3d, + IrradianceUnit.MegawattPerSquareCentimeter => (_value*10000) * 1e6d, + IrradianceUnit.MegawattPerSquareMeter => (_value) * 1e6d, + IrradianceUnit.MicrowattPerSquareCentimeter => (_value*10000) * 1e-6d, + IrradianceUnit.MicrowattPerSquareMeter => (_value) * 1e-6d, + IrradianceUnit.MilliwattPerSquareCentimeter => (_value*10000) * 1e-3d, + IrradianceUnit.MilliwattPerSquareMeter => (_value) * 1e-3d, + IrradianceUnit.NanowattPerSquareCentimeter => (_value*10000) * 1e-9d, + IrradianceUnit.NanowattPerSquareMeter => (_value) * 1e-9d, + IrradianceUnit.PicowattPerSquareCentimeter => (_value*10000) * 1e-12d, + IrradianceUnit.PicowattPerSquareMeter => (_value) * 1e-12d, + IrradianceUnit.WattPerSquareCentimeter => _value*10000, + IrradianceUnit.WattPerSquareMeter => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(IrradianceUnit unit) @@ -302,25 +301,24 @@ private double GetValueAs(IrradianceUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case IrradianceUnit.KilowattPerSquareCentimeter: return (baseUnitValue*0.0001) / 1e3d; - case IrradianceUnit.KilowattPerSquareMeter: return (baseUnitValue) / 1e3d; - case IrradianceUnit.MegawattPerSquareCentimeter: return (baseUnitValue*0.0001) / 1e6d; - case IrradianceUnit.MegawattPerSquareMeter: return (baseUnitValue) / 1e6d; - case IrradianceUnit.MicrowattPerSquareCentimeter: return (baseUnitValue*0.0001) / 1e-6d; - case IrradianceUnit.MicrowattPerSquareMeter: return (baseUnitValue) / 1e-6d; - case IrradianceUnit.MilliwattPerSquareCentimeter: return (baseUnitValue*0.0001) / 1e-3d; - case IrradianceUnit.MilliwattPerSquareMeter: return (baseUnitValue) / 1e-3d; - case IrradianceUnit.NanowattPerSquareCentimeter: return (baseUnitValue*0.0001) / 1e-9d; - case IrradianceUnit.NanowattPerSquareMeter: return (baseUnitValue) / 1e-9d; - case IrradianceUnit.PicowattPerSquareCentimeter: return (baseUnitValue*0.0001) / 1e-12d; - case IrradianceUnit.PicowattPerSquareMeter: return (baseUnitValue) / 1e-12d; - case IrradianceUnit.WattPerSquareCentimeter: return baseUnitValue*0.0001; - case IrradianceUnit.WattPerSquareMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + IrradianceUnit.KilowattPerSquareCentimeter => (baseUnitValue*0.0001) / 1e3d, + IrradianceUnit.KilowattPerSquareMeter => (baseUnitValue) / 1e3d, + IrradianceUnit.MegawattPerSquareCentimeter => (baseUnitValue*0.0001) / 1e6d, + IrradianceUnit.MegawattPerSquareMeter => (baseUnitValue) / 1e6d, + IrradianceUnit.MicrowattPerSquareCentimeter => (baseUnitValue*0.0001) / 1e-6d, + IrradianceUnit.MicrowattPerSquareMeter => (baseUnitValue) / 1e-6d, + IrradianceUnit.MilliwattPerSquareCentimeter => (baseUnitValue*0.0001) / 1e-3d, + IrradianceUnit.MilliwattPerSquareMeter => (baseUnitValue) / 1e-3d, + IrradianceUnit.NanowattPerSquareCentimeter => (baseUnitValue*0.0001) / 1e-9d, + IrradianceUnit.NanowattPerSquareMeter => (baseUnitValue) / 1e-9d, + IrradianceUnit.PicowattPerSquareCentimeter => (baseUnitValue*0.0001) / 1e-12d, + IrradianceUnit.PicowattPerSquareMeter => (baseUnitValue) / 1e-12d, + IrradianceUnit.WattPerSquareCentimeter => baseUnitValue*0.0001, + IrradianceUnit.WattPerSquareMeter => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs index 6e21675916..c07043aebb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs @@ -200,18 +200,17 @@ public Irradiation ToUnit(IrradiationUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case IrradiationUnit.JoulePerSquareCentimeter: return _value*1e4; - case IrradiationUnit.JoulePerSquareMeter: return _value; - case IrradiationUnit.JoulePerSquareMillimeter: return _value*1e6; - case IrradiationUnit.KilojoulePerSquareMeter: return (_value) * 1e3d; - case IrradiationUnit.KilowattHourPerSquareMeter: return (_value*3600d) * 1e3d; - case IrradiationUnit.MillijoulePerSquareCentimeter: return (_value*1e4) * 1e-3d; - case IrradiationUnit.WattHourPerSquareMeter: return _value*3600d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + IrradiationUnit.JoulePerSquareCentimeter => _value*1e4, + IrradiationUnit.JoulePerSquareMeter => _value, + IrradiationUnit.JoulePerSquareMillimeter => _value*1e6, + IrradiationUnit.KilojoulePerSquareMeter => (_value) * 1e3d, + IrradiationUnit.KilowattHourPerSquareMeter => (_value*3600d) * 1e3d, + IrradiationUnit.MillijoulePerSquareCentimeter => (_value*1e4) * 1e-3d, + IrradiationUnit.WattHourPerSquareMeter => _value*3600d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(IrradiationUnit unit) @@ -221,18 +220,17 @@ private double GetValueAs(IrradiationUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case IrradiationUnit.JoulePerSquareCentimeter: return baseUnitValue/1e4; - case IrradiationUnit.JoulePerSquareMeter: return baseUnitValue; - case IrradiationUnit.JoulePerSquareMillimeter: return baseUnitValue/1e6; - case IrradiationUnit.KilojoulePerSquareMeter: return (baseUnitValue) / 1e3d; - case IrradiationUnit.KilowattHourPerSquareMeter: return (baseUnitValue/3600d) / 1e3d; - case IrradiationUnit.MillijoulePerSquareCentimeter: return (baseUnitValue/1e4) / 1e-3d; - case IrradiationUnit.WattHourPerSquareMeter: return baseUnitValue/3600d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + IrradiationUnit.JoulePerSquareCentimeter => baseUnitValue/1e4, + IrradiationUnit.JoulePerSquareMeter => baseUnitValue, + IrradiationUnit.JoulePerSquareMillimeter => baseUnitValue/1e6, + IrradiationUnit.KilojoulePerSquareMeter => (baseUnitValue) / 1e3d, + IrradiationUnit.KilowattHourPerSquareMeter => (baseUnitValue/3600d) / 1e3d, + IrradiationUnit.MillijoulePerSquareCentimeter => (baseUnitValue/1e4) / 1e-3d, + IrradiationUnit.WattHourPerSquareMeter => baseUnitValue/3600d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/KinematicViscosity.g.cs index 8943529b2a..a989b6f423 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -222,20 +222,19 @@ public KinematicViscosity ToUnit(KinematicViscosityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case KinematicViscosityUnit.Centistokes: return (_value/1e4) * 1e-2d; - case KinematicViscosityUnit.Decistokes: return (_value/1e4) * 1e-1d; - case KinematicViscosityUnit.Kilostokes: return (_value/1e4) * 1e3d; - case KinematicViscosityUnit.Microstokes: return (_value/1e4) * 1e-6d; - case KinematicViscosityUnit.Millistokes: return (_value/1e4) * 1e-3d; - case KinematicViscosityUnit.Nanostokes: return (_value/1e4) * 1e-9d; - case KinematicViscosityUnit.SquareFootPerSecond: return _value/10.7639; - case KinematicViscosityUnit.SquareMeterPerSecond: return _value; - case KinematicViscosityUnit.Stokes: return _value/1e4; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + KinematicViscosityUnit.Centistokes => (_value/1e4) * 1e-2d, + KinematicViscosityUnit.Decistokes => (_value/1e4) * 1e-1d, + KinematicViscosityUnit.Kilostokes => (_value/1e4) * 1e3d, + KinematicViscosityUnit.Microstokes => (_value/1e4) * 1e-6d, + KinematicViscosityUnit.Millistokes => (_value/1e4) * 1e-3d, + KinematicViscosityUnit.Nanostokes => (_value/1e4) * 1e-9d, + KinematicViscosityUnit.SquareFootPerSecond => _value/10.7639, + KinematicViscosityUnit.SquareMeterPerSecond => _value, + KinematicViscosityUnit.Stokes => _value/1e4, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(KinematicViscosityUnit unit) @@ -245,20 +244,19 @@ private double GetValueAs(KinematicViscosityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case KinematicViscosityUnit.Centistokes: return (baseUnitValue*1e4) / 1e-2d; - case KinematicViscosityUnit.Decistokes: return (baseUnitValue*1e4) / 1e-1d; - case KinematicViscosityUnit.Kilostokes: return (baseUnitValue*1e4) / 1e3d; - case KinematicViscosityUnit.Microstokes: return (baseUnitValue*1e4) / 1e-6d; - case KinematicViscosityUnit.Millistokes: return (baseUnitValue*1e4) / 1e-3d; - case KinematicViscosityUnit.Nanostokes: return (baseUnitValue*1e4) / 1e-9d; - case KinematicViscosityUnit.SquareFootPerSecond: return baseUnitValue*10.7639; - case KinematicViscosityUnit.SquareMeterPerSecond: return baseUnitValue; - case KinematicViscosityUnit.Stokes: return baseUnitValue*1e4; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + KinematicViscosityUnit.Centistokes => (baseUnitValue*1e4) / 1e-2d, + KinematicViscosityUnit.Decistokes => (baseUnitValue*1e4) / 1e-1d, + KinematicViscosityUnit.Kilostokes => (baseUnitValue*1e4) / 1e3d, + KinematicViscosityUnit.Microstokes => (baseUnitValue*1e4) / 1e-6d, + KinematicViscosityUnit.Millistokes => (baseUnitValue*1e4) / 1e-3d, + KinematicViscosityUnit.Nanostokes => (baseUnitValue*1e4) / 1e-9d, + KinematicViscosityUnit.SquareFootPerSecond => baseUnitValue*10.7639, + KinematicViscosityUnit.SquareMeterPerSecond => baseUnitValue, + KinematicViscosityUnit.Stokes => baseUnitValue*1e4, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LapseRate.g.cs index 1e7fb4acba..6913a7c7bd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LapseRate.g.cs @@ -131,12 +131,11 @@ public LapseRate ToUnit(LapseRateUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case LapseRateUnit.DegreeCelsiusPerKilometer: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + LapseRateUnit.DegreeCelsiusPerKilometer => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(LapseRateUnit unit) @@ -146,12 +145,11 @@ private double GetValueAs(LapseRateUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case LapseRateUnit.DegreeCelsiusPerKilometer: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + LapseRateUnit.DegreeCelsiusPerKilometer => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Length.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Length.g.cs index ad4f5d990f..d1ff140aba 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Length.g.cs @@ -494,45 +494,44 @@ public Length ToUnit(LengthUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case LengthUnit.AstronomicalUnit: return _value * 1.4959787070e11; - case LengthUnit.Centimeter: return (_value) * 1e-2d; - case LengthUnit.Chain: return _value*20.1168; - case LengthUnit.Decameter: return (_value) * 1e1d; - case LengthUnit.Decimeter: return (_value) * 1e-1d; - case LengthUnit.DtpPica: return _value/236.220472441; - case LengthUnit.DtpPoint: return (_value/72)*2.54e-2; - case LengthUnit.Fathom: return _value*1.8288; - case LengthUnit.Foot: return _value*0.3048; - case LengthUnit.Hand: return _value * 1.016e-1; - case LengthUnit.Hectometer: return (_value) * 1e2d; - case LengthUnit.Inch: return _value*2.54e-2; - case LengthUnit.KilolightYear: return (_value * 9.46073047258e15) * 1e3d; - case LengthUnit.Kilometer: return (_value) * 1e3d; - case LengthUnit.Kiloparsec: return (_value * 3.08567758128e16) * 1e3d; - case LengthUnit.LightYear: return _value * 9.46073047258e15; - case LengthUnit.MegalightYear: return (_value * 9.46073047258e15) * 1e6d; - case LengthUnit.Megaparsec: return (_value * 3.08567758128e16) * 1e6d; - case LengthUnit.Meter: return _value; - case LengthUnit.Microinch: return _value*2.54e-8; - case LengthUnit.Micrometer: return (_value) * 1e-6d; - case LengthUnit.Mil: return _value*2.54e-5; - case LengthUnit.Mile: return _value*1609.34; - case LengthUnit.Millimeter: return (_value) * 1e-3d; - case LengthUnit.Nanometer: return (_value) * 1e-9d; - case LengthUnit.NauticalMile: return _value*1852; - case LengthUnit.Parsec: return _value * 3.08567758128e16; - case LengthUnit.PrinterPica: return _value/237.106301584; - case LengthUnit.PrinterPoint: return (_value/72.27)*2.54e-2; - case LengthUnit.Shackle: return _value*27.432; - case LengthUnit.SolarRadius: return _value * 6.95510000E+08; - case LengthUnit.Twip: return _value/56692.913385826; - case LengthUnit.UsSurveyFoot: return _value*1200/3937; - case LengthUnit.Yard: return _value*0.9144; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + LengthUnit.AstronomicalUnit => _value * 1.4959787070e11, + LengthUnit.Centimeter => (_value) * 1e-2d, + LengthUnit.Chain => _value*20.1168, + LengthUnit.Decameter => (_value) * 1e1d, + LengthUnit.Decimeter => (_value) * 1e-1d, + LengthUnit.DtpPica => _value/236.220472441, + LengthUnit.DtpPoint => (_value/72)*2.54e-2, + LengthUnit.Fathom => _value*1.8288, + LengthUnit.Foot => _value*0.3048, + LengthUnit.Hand => _value * 1.016e-1, + LengthUnit.Hectometer => (_value) * 1e2d, + LengthUnit.Inch => _value*2.54e-2, + LengthUnit.KilolightYear => (_value * 9.46073047258e15) * 1e3d, + LengthUnit.Kilometer => (_value) * 1e3d, + LengthUnit.Kiloparsec => (_value * 3.08567758128e16) * 1e3d, + LengthUnit.LightYear => _value * 9.46073047258e15, + LengthUnit.MegalightYear => (_value * 9.46073047258e15) * 1e6d, + LengthUnit.Megaparsec => (_value * 3.08567758128e16) * 1e6d, + LengthUnit.Meter => _value, + LengthUnit.Microinch => _value*2.54e-8, + LengthUnit.Micrometer => (_value) * 1e-6d, + LengthUnit.Mil => _value*2.54e-5, + LengthUnit.Mile => _value*1609.34, + LengthUnit.Millimeter => (_value) * 1e-3d, + LengthUnit.Nanometer => (_value) * 1e-9d, + LengthUnit.NauticalMile => _value*1852, + LengthUnit.Parsec => _value * 3.08567758128e16, + LengthUnit.PrinterPica => _value/237.106301584, + LengthUnit.PrinterPoint => (_value/72.27)*2.54e-2, + LengthUnit.Shackle => _value*27.432, + LengthUnit.SolarRadius => _value * 6.95510000E+08, + LengthUnit.Twip => _value/56692.913385826, + LengthUnit.UsSurveyFoot => _value*1200/3937, + LengthUnit.Yard => _value*0.9144, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(LengthUnit unit) @@ -542,45 +541,44 @@ private double GetValueAs(LengthUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case LengthUnit.AstronomicalUnit: return baseUnitValue / 1.4959787070e11; - case LengthUnit.Centimeter: return (baseUnitValue) / 1e-2d; - case LengthUnit.Chain: return baseUnitValue/20.1168; - case LengthUnit.Decameter: return (baseUnitValue) / 1e1d; - case LengthUnit.Decimeter: return (baseUnitValue) / 1e-1d; - case LengthUnit.DtpPica: return baseUnitValue*236.220472441; - case LengthUnit.DtpPoint: return (baseUnitValue/2.54e-2)*72; - case LengthUnit.Fathom: return baseUnitValue/1.8288; - case LengthUnit.Foot: return baseUnitValue/0.3048; - case LengthUnit.Hand: return baseUnitValue / 1.016e-1; - case LengthUnit.Hectometer: return (baseUnitValue) / 1e2d; - case LengthUnit.Inch: return baseUnitValue/2.54e-2; - case LengthUnit.KilolightYear: return (baseUnitValue / 9.46073047258e15) / 1e3d; - case LengthUnit.Kilometer: return (baseUnitValue) / 1e3d; - case LengthUnit.Kiloparsec: return (baseUnitValue / 3.08567758128e16) / 1e3d; - case LengthUnit.LightYear: return baseUnitValue / 9.46073047258e15; - case LengthUnit.MegalightYear: return (baseUnitValue / 9.46073047258e15) / 1e6d; - case LengthUnit.Megaparsec: return (baseUnitValue / 3.08567758128e16) / 1e6d; - case LengthUnit.Meter: return baseUnitValue; - case LengthUnit.Microinch: return baseUnitValue/2.54e-8; - case LengthUnit.Micrometer: return (baseUnitValue) / 1e-6d; - case LengthUnit.Mil: return baseUnitValue/2.54e-5; - case LengthUnit.Mile: return baseUnitValue/1609.34; - case LengthUnit.Millimeter: return (baseUnitValue) / 1e-3d; - case LengthUnit.Nanometer: return (baseUnitValue) / 1e-9d; - case LengthUnit.NauticalMile: return baseUnitValue/1852; - case LengthUnit.Parsec: return baseUnitValue / 3.08567758128e16; - case LengthUnit.PrinterPica: return baseUnitValue*237.106301584; - case LengthUnit.PrinterPoint: return (baseUnitValue/2.54e-2)*72.27; - case LengthUnit.Shackle: return baseUnitValue/27.432; - case LengthUnit.SolarRadius: return baseUnitValue / 6.95510000E+08; - case LengthUnit.Twip: return baseUnitValue*56692.913385826; - case LengthUnit.UsSurveyFoot: return baseUnitValue*3937/1200; - case LengthUnit.Yard: return baseUnitValue/0.9144; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + LengthUnit.AstronomicalUnit => baseUnitValue / 1.4959787070e11, + LengthUnit.Centimeter => (baseUnitValue) / 1e-2d, + LengthUnit.Chain => baseUnitValue/20.1168, + LengthUnit.Decameter => (baseUnitValue) / 1e1d, + LengthUnit.Decimeter => (baseUnitValue) / 1e-1d, + LengthUnit.DtpPica => baseUnitValue*236.220472441, + LengthUnit.DtpPoint => (baseUnitValue/2.54e-2)*72, + LengthUnit.Fathom => baseUnitValue/1.8288, + LengthUnit.Foot => baseUnitValue/0.3048, + LengthUnit.Hand => baseUnitValue / 1.016e-1, + LengthUnit.Hectometer => (baseUnitValue) / 1e2d, + LengthUnit.Inch => baseUnitValue/2.54e-2, + LengthUnit.KilolightYear => (baseUnitValue / 9.46073047258e15) / 1e3d, + LengthUnit.Kilometer => (baseUnitValue) / 1e3d, + LengthUnit.Kiloparsec => (baseUnitValue / 3.08567758128e16) / 1e3d, + LengthUnit.LightYear => baseUnitValue / 9.46073047258e15, + LengthUnit.MegalightYear => (baseUnitValue / 9.46073047258e15) / 1e6d, + LengthUnit.Megaparsec => (baseUnitValue / 3.08567758128e16) / 1e6d, + LengthUnit.Meter => baseUnitValue, + LengthUnit.Microinch => baseUnitValue/2.54e-8, + LengthUnit.Micrometer => (baseUnitValue) / 1e-6d, + LengthUnit.Mil => baseUnitValue/2.54e-5, + LengthUnit.Mile => baseUnitValue/1609.34, + LengthUnit.Millimeter => (baseUnitValue) / 1e-3d, + LengthUnit.Nanometer => (baseUnitValue) / 1e-9d, + LengthUnit.NauticalMile => baseUnitValue/1852, + LengthUnit.Parsec => baseUnitValue / 3.08567758128e16, + LengthUnit.PrinterPica => baseUnitValue*237.106301584, + LengthUnit.PrinterPoint => (baseUnitValue/2.54e-2)*72.27, + LengthUnit.Shackle => baseUnitValue/27.432, + LengthUnit.SolarRadius => baseUnitValue / 6.95510000E+08, + LengthUnit.Twip => baseUnitValue*56692.913385826, + LengthUnit.UsSurveyFoot => baseUnitValue*3937/1200, + LengthUnit.Yard => baseUnitValue/0.9144, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Level.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Level.g.cs index d938fb9c1d..3ea4bfe7c0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Level.g.cs @@ -142,13 +142,12 @@ public Level ToUnit(LevelUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case LevelUnit.Decibel: return _value; - case LevelUnit.Neper: return (1/0.115129254)*_value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + LevelUnit.Decibel => _value, + LevelUnit.Neper => (1/0.115129254)*_value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(LevelUnit unit) @@ -158,13 +157,12 @@ private double GetValueAs(LevelUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case LevelUnit.Decibel: return baseUnitValue; - case LevelUnit.Neper: return 0.115129254*baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + LevelUnit.Decibel => baseUnitValue, + LevelUnit.Neper => 0.115129254*baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearDensity.g.cs index a39f73aa19..35acacc02f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearDensity.g.cs @@ -277,25 +277,24 @@ public LinearDensity ToUnit(LinearDensityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case LinearDensityUnit.GramPerCentimeter: return _value*1e-1; - case LinearDensityUnit.GramPerMeter: return _value*1e-3; - case LinearDensityUnit.GramPerMillimeter: return _value; - case LinearDensityUnit.KilogramPerCentimeter: return (_value*1e-1) * 1e3d; - case LinearDensityUnit.KilogramPerMeter: return (_value*1e-3) * 1e3d; - case LinearDensityUnit.KilogramPerMillimeter: return (_value) * 1e3d; - case LinearDensityUnit.MicrogramPerCentimeter: return (_value*1e-1) * 1e-6d; - case LinearDensityUnit.MicrogramPerMeter: return (_value*1e-3) * 1e-6d; - case LinearDensityUnit.MicrogramPerMillimeter: return (_value) * 1e-6d; - case LinearDensityUnit.MilligramPerCentimeter: return (_value*1e-1) * 1e-3d; - case LinearDensityUnit.MilligramPerMeter: return (_value*1e-3) * 1e-3d; - case LinearDensityUnit.MilligramPerMillimeter: return (_value) * 1e-3d; - case LinearDensityUnit.PoundPerFoot: return _value*1.48816394; - case LinearDensityUnit.PoundPerInch: return _value/5.5997415e-2; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + LinearDensityUnit.GramPerCentimeter => _value*1e-1, + LinearDensityUnit.GramPerMeter => _value*1e-3, + LinearDensityUnit.GramPerMillimeter => _value, + LinearDensityUnit.KilogramPerCentimeter => (_value*1e-1) * 1e3d, + LinearDensityUnit.KilogramPerMeter => (_value*1e-3) * 1e3d, + LinearDensityUnit.KilogramPerMillimeter => (_value) * 1e3d, + LinearDensityUnit.MicrogramPerCentimeter => (_value*1e-1) * 1e-6d, + LinearDensityUnit.MicrogramPerMeter => (_value*1e-3) * 1e-6d, + LinearDensityUnit.MicrogramPerMillimeter => (_value) * 1e-6d, + LinearDensityUnit.MilligramPerCentimeter => (_value*1e-1) * 1e-3d, + LinearDensityUnit.MilligramPerMeter => (_value*1e-3) * 1e-3d, + LinearDensityUnit.MilligramPerMillimeter => (_value) * 1e-3d, + LinearDensityUnit.PoundPerFoot => _value*1.48816394, + LinearDensityUnit.PoundPerInch => _value/5.5997415e-2, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(LinearDensityUnit unit) @@ -305,25 +304,24 @@ private double GetValueAs(LinearDensityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case LinearDensityUnit.GramPerCentimeter: return baseUnitValue/1e-1; - case LinearDensityUnit.GramPerMeter: return baseUnitValue/1e-3; - case LinearDensityUnit.GramPerMillimeter: return baseUnitValue; - case LinearDensityUnit.KilogramPerCentimeter: return (baseUnitValue/1e-1) / 1e3d; - case LinearDensityUnit.KilogramPerMeter: return (baseUnitValue/1e-3) / 1e3d; - case LinearDensityUnit.KilogramPerMillimeter: return (baseUnitValue) / 1e3d; - case LinearDensityUnit.MicrogramPerCentimeter: return (baseUnitValue/1e-1) / 1e-6d; - case LinearDensityUnit.MicrogramPerMeter: return (baseUnitValue/1e-3) / 1e-6d; - case LinearDensityUnit.MicrogramPerMillimeter: return (baseUnitValue) / 1e-6d; - case LinearDensityUnit.MilligramPerCentimeter: return (baseUnitValue/1e-1) / 1e-3d; - case LinearDensityUnit.MilligramPerMeter: return (baseUnitValue/1e-3) / 1e-3d; - case LinearDensityUnit.MilligramPerMillimeter: return (baseUnitValue) / 1e-3d; - case LinearDensityUnit.PoundPerFoot: return baseUnitValue/1.48816394; - case LinearDensityUnit.PoundPerInch: return baseUnitValue*5.5997415e-2; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + LinearDensityUnit.GramPerCentimeter => baseUnitValue/1e-1, + LinearDensityUnit.GramPerMeter => baseUnitValue/1e-3, + LinearDensityUnit.GramPerMillimeter => baseUnitValue, + LinearDensityUnit.KilogramPerCentimeter => (baseUnitValue/1e-1) / 1e3d, + LinearDensityUnit.KilogramPerMeter => (baseUnitValue/1e-3) / 1e3d, + LinearDensityUnit.KilogramPerMillimeter => (baseUnitValue) / 1e3d, + LinearDensityUnit.MicrogramPerCentimeter => (baseUnitValue/1e-1) / 1e-6d, + LinearDensityUnit.MicrogramPerMeter => (baseUnitValue/1e-3) / 1e-6d, + LinearDensityUnit.MicrogramPerMillimeter => (baseUnitValue) / 1e-6d, + LinearDensityUnit.MilligramPerCentimeter => (baseUnitValue/1e-1) / 1e-3d, + LinearDensityUnit.MilligramPerMeter => (baseUnitValue/1e-3) / 1e-3d, + LinearDensityUnit.MilligramPerMillimeter => (baseUnitValue) / 1e-3d, + LinearDensityUnit.PoundPerFoot => baseUnitValue/1.48816394, + LinearDensityUnit.PoundPerInch => baseUnitValue*5.5997415e-2, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearPowerDensity.g.cs index 00286dd011..958061f364 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -398,36 +398,35 @@ public LinearPowerDensity ToUnit(LinearPowerDensityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case LinearPowerDensityUnit.GigawattPerCentimeter: return (_value*1e2) * 1e9d; - case LinearPowerDensityUnit.GigawattPerFoot: return (_value*3.280839895) * 1e9d; - case LinearPowerDensityUnit.GigawattPerInch: return (_value*39.37007874) * 1e9d; - case LinearPowerDensityUnit.GigawattPerMeter: return (_value) * 1e9d; - case LinearPowerDensityUnit.GigawattPerMillimeter: return (_value*1e3) * 1e9d; - case LinearPowerDensityUnit.KilowattPerCentimeter: return (_value*1e2) * 1e3d; - case LinearPowerDensityUnit.KilowattPerFoot: return (_value*3.280839895) * 1e3d; - case LinearPowerDensityUnit.KilowattPerInch: return (_value*39.37007874) * 1e3d; - case LinearPowerDensityUnit.KilowattPerMeter: return (_value) * 1e3d; - case LinearPowerDensityUnit.KilowattPerMillimeter: return (_value*1e3) * 1e3d; - case LinearPowerDensityUnit.MegawattPerCentimeter: return (_value*1e2) * 1e6d; - case LinearPowerDensityUnit.MegawattPerFoot: return (_value*3.280839895) * 1e6d; - case LinearPowerDensityUnit.MegawattPerInch: return (_value*39.37007874) * 1e6d; - case LinearPowerDensityUnit.MegawattPerMeter: return (_value) * 1e6d; - case LinearPowerDensityUnit.MegawattPerMillimeter: return (_value*1e3) * 1e6d; - case LinearPowerDensityUnit.MilliwattPerCentimeter: return (_value*1e2) * 1e-3d; - case LinearPowerDensityUnit.MilliwattPerFoot: return (_value*3.280839895) * 1e-3d; - case LinearPowerDensityUnit.MilliwattPerInch: return (_value*39.37007874) * 1e-3d; - case LinearPowerDensityUnit.MilliwattPerMeter: return (_value) * 1e-3d; - case LinearPowerDensityUnit.MilliwattPerMillimeter: return (_value*1e3) * 1e-3d; - case LinearPowerDensityUnit.WattPerCentimeter: return _value*1e2; - case LinearPowerDensityUnit.WattPerFoot: return _value*3.280839895; - case LinearPowerDensityUnit.WattPerInch: return _value*39.37007874; - case LinearPowerDensityUnit.WattPerMeter: return _value; - case LinearPowerDensityUnit.WattPerMillimeter: return _value*1e3; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + LinearPowerDensityUnit.GigawattPerCentimeter => (_value*1e2) * 1e9d, + LinearPowerDensityUnit.GigawattPerFoot => (_value*3.280839895) * 1e9d, + LinearPowerDensityUnit.GigawattPerInch => (_value*39.37007874) * 1e9d, + LinearPowerDensityUnit.GigawattPerMeter => (_value) * 1e9d, + LinearPowerDensityUnit.GigawattPerMillimeter => (_value*1e3) * 1e9d, + LinearPowerDensityUnit.KilowattPerCentimeter => (_value*1e2) * 1e3d, + LinearPowerDensityUnit.KilowattPerFoot => (_value*3.280839895) * 1e3d, + LinearPowerDensityUnit.KilowattPerInch => (_value*39.37007874) * 1e3d, + LinearPowerDensityUnit.KilowattPerMeter => (_value) * 1e3d, + LinearPowerDensityUnit.KilowattPerMillimeter => (_value*1e3) * 1e3d, + LinearPowerDensityUnit.MegawattPerCentimeter => (_value*1e2) * 1e6d, + LinearPowerDensityUnit.MegawattPerFoot => (_value*3.280839895) * 1e6d, + LinearPowerDensityUnit.MegawattPerInch => (_value*39.37007874) * 1e6d, + LinearPowerDensityUnit.MegawattPerMeter => (_value) * 1e6d, + LinearPowerDensityUnit.MegawattPerMillimeter => (_value*1e3) * 1e6d, + LinearPowerDensityUnit.MilliwattPerCentimeter => (_value*1e2) * 1e-3d, + LinearPowerDensityUnit.MilliwattPerFoot => (_value*3.280839895) * 1e-3d, + LinearPowerDensityUnit.MilliwattPerInch => (_value*39.37007874) * 1e-3d, + LinearPowerDensityUnit.MilliwattPerMeter => (_value) * 1e-3d, + LinearPowerDensityUnit.MilliwattPerMillimeter => (_value*1e3) * 1e-3d, + LinearPowerDensityUnit.WattPerCentimeter => _value*1e2, + LinearPowerDensityUnit.WattPerFoot => _value*3.280839895, + LinearPowerDensityUnit.WattPerInch => _value*39.37007874, + LinearPowerDensityUnit.WattPerMeter => _value, + LinearPowerDensityUnit.WattPerMillimeter => _value*1e3, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(LinearPowerDensityUnit unit) @@ -437,36 +436,35 @@ private double GetValueAs(LinearPowerDensityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case LinearPowerDensityUnit.GigawattPerCentimeter: return (baseUnitValue/1e2) / 1e9d; - case LinearPowerDensityUnit.GigawattPerFoot: return (baseUnitValue/3.280839895) / 1e9d; - case LinearPowerDensityUnit.GigawattPerInch: return (baseUnitValue/39.37007874) / 1e9d; - case LinearPowerDensityUnit.GigawattPerMeter: return (baseUnitValue) / 1e9d; - case LinearPowerDensityUnit.GigawattPerMillimeter: return (baseUnitValue/1e3) / 1e9d; - case LinearPowerDensityUnit.KilowattPerCentimeter: return (baseUnitValue/1e2) / 1e3d; - case LinearPowerDensityUnit.KilowattPerFoot: return (baseUnitValue/3.280839895) / 1e3d; - case LinearPowerDensityUnit.KilowattPerInch: return (baseUnitValue/39.37007874) / 1e3d; - case LinearPowerDensityUnit.KilowattPerMeter: return (baseUnitValue) / 1e3d; - case LinearPowerDensityUnit.KilowattPerMillimeter: return (baseUnitValue/1e3) / 1e3d; - case LinearPowerDensityUnit.MegawattPerCentimeter: return (baseUnitValue/1e2) / 1e6d; - case LinearPowerDensityUnit.MegawattPerFoot: return (baseUnitValue/3.280839895) / 1e6d; - case LinearPowerDensityUnit.MegawattPerInch: return (baseUnitValue/39.37007874) / 1e6d; - case LinearPowerDensityUnit.MegawattPerMeter: return (baseUnitValue) / 1e6d; - case LinearPowerDensityUnit.MegawattPerMillimeter: return (baseUnitValue/1e3) / 1e6d; - case LinearPowerDensityUnit.MilliwattPerCentimeter: return (baseUnitValue/1e2) / 1e-3d; - case LinearPowerDensityUnit.MilliwattPerFoot: return (baseUnitValue/3.280839895) / 1e-3d; - case LinearPowerDensityUnit.MilliwattPerInch: return (baseUnitValue/39.37007874) / 1e-3d; - case LinearPowerDensityUnit.MilliwattPerMeter: return (baseUnitValue) / 1e-3d; - case LinearPowerDensityUnit.MilliwattPerMillimeter: return (baseUnitValue/1e3) / 1e-3d; - case LinearPowerDensityUnit.WattPerCentimeter: return baseUnitValue/1e2; - case LinearPowerDensityUnit.WattPerFoot: return baseUnitValue/3.280839895; - case LinearPowerDensityUnit.WattPerInch: return baseUnitValue/39.37007874; - case LinearPowerDensityUnit.WattPerMeter: return baseUnitValue; - case LinearPowerDensityUnit.WattPerMillimeter: return baseUnitValue/1e3; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + LinearPowerDensityUnit.GigawattPerCentimeter => (baseUnitValue/1e2) / 1e9d, + LinearPowerDensityUnit.GigawattPerFoot => (baseUnitValue/3.280839895) / 1e9d, + LinearPowerDensityUnit.GigawattPerInch => (baseUnitValue/39.37007874) / 1e9d, + LinearPowerDensityUnit.GigawattPerMeter => (baseUnitValue) / 1e9d, + LinearPowerDensityUnit.GigawattPerMillimeter => (baseUnitValue/1e3) / 1e9d, + LinearPowerDensityUnit.KilowattPerCentimeter => (baseUnitValue/1e2) / 1e3d, + LinearPowerDensityUnit.KilowattPerFoot => (baseUnitValue/3.280839895) / 1e3d, + LinearPowerDensityUnit.KilowattPerInch => (baseUnitValue/39.37007874) / 1e3d, + LinearPowerDensityUnit.KilowattPerMeter => (baseUnitValue) / 1e3d, + LinearPowerDensityUnit.KilowattPerMillimeter => (baseUnitValue/1e3) / 1e3d, + LinearPowerDensityUnit.MegawattPerCentimeter => (baseUnitValue/1e2) / 1e6d, + LinearPowerDensityUnit.MegawattPerFoot => (baseUnitValue/3.280839895) / 1e6d, + LinearPowerDensityUnit.MegawattPerInch => (baseUnitValue/39.37007874) / 1e6d, + LinearPowerDensityUnit.MegawattPerMeter => (baseUnitValue) / 1e6d, + LinearPowerDensityUnit.MegawattPerMillimeter => (baseUnitValue/1e3) / 1e6d, + LinearPowerDensityUnit.MilliwattPerCentimeter => (baseUnitValue/1e2) / 1e-3d, + LinearPowerDensityUnit.MilliwattPerFoot => (baseUnitValue/3.280839895) / 1e-3d, + LinearPowerDensityUnit.MilliwattPerInch => (baseUnitValue/39.37007874) / 1e-3d, + LinearPowerDensityUnit.MilliwattPerMeter => (baseUnitValue) / 1e-3d, + LinearPowerDensityUnit.MilliwattPerMillimeter => (baseUnitValue/1e3) / 1e-3d, + LinearPowerDensityUnit.WattPerCentimeter => baseUnitValue/1e2, + LinearPowerDensityUnit.WattPerFoot => baseUnitValue/3.280839895, + LinearPowerDensityUnit.WattPerInch => baseUnitValue/39.37007874, + LinearPowerDensityUnit.WattPerMeter => baseUnitValue, + LinearPowerDensityUnit.WattPerMillimeter => baseUnitValue/1e3, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Luminosity.g.cs index 77c6220740..3122294c4c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Luminosity.g.cs @@ -277,25 +277,24 @@ public Luminosity ToUnit(LuminosityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case LuminosityUnit.Decawatt: return (_value) * 1e1d; - case LuminosityUnit.Deciwatt: return (_value) * 1e-1d; - case LuminosityUnit.Femtowatt: return (_value) * 1e-15d; - case LuminosityUnit.Gigawatt: return (_value) * 1e9d; - case LuminosityUnit.Kilowatt: return (_value) * 1e3d; - case LuminosityUnit.Megawatt: return (_value) * 1e6d; - case LuminosityUnit.Microwatt: return (_value) * 1e-6d; - case LuminosityUnit.Milliwatt: return (_value) * 1e-3d; - case LuminosityUnit.Nanowatt: return (_value) * 1e-9d; - case LuminosityUnit.Petawatt: return (_value) * 1e15d; - case LuminosityUnit.Picowatt: return (_value) * 1e-12d; - case LuminosityUnit.SolarLuminosity: return _value * 3.846e26; - case LuminosityUnit.Terawatt: return (_value) * 1e12d; - case LuminosityUnit.Watt: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + LuminosityUnit.Decawatt => (_value) * 1e1d, + LuminosityUnit.Deciwatt => (_value) * 1e-1d, + LuminosityUnit.Femtowatt => (_value) * 1e-15d, + LuminosityUnit.Gigawatt => (_value) * 1e9d, + LuminosityUnit.Kilowatt => (_value) * 1e3d, + LuminosityUnit.Megawatt => (_value) * 1e6d, + LuminosityUnit.Microwatt => (_value) * 1e-6d, + LuminosityUnit.Milliwatt => (_value) * 1e-3d, + LuminosityUnit.Nanowatt => (_value) * 1e-9d, + LuminosityUnit.Petawatt => (_value) * 1e15d, + LuminosityUnit.Picowatt => (_value) * 1e-12d, + LuminosityUnit.SolarLuminosity => _value * 3.846e26, + LuminosityUnit.Terawatt => (_value) * 1e12d, + LuminosityUnit.Watt => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(LuminosityUnit unit) @@ -305,25 +304,24 @@ private double GetValueAs(LuminosityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case LuminosityUnit.Decawatt: return (baseUnitValue) / 1e1d; - case LuminosityUnit.Deciwatt: return (baseUnitValue) / 1e-1d; - case LuminosityUnit.Femtowatt: return (baseUnitValue) / 1e-15d; - case LuminosityUnit.Gigawatt: return (baseUnitValue) / 1e9d; - case LuminosityUnit.Kilowatt: return (baseUnitValue) / 1e3d; - case LuminosityUnit.Megawatt: return (baseUnitValue) / 1e6d; - case LuminosityUnit.Microwatt: return (baseUnitValue) / 1e-6d; - case LuminosityUnit.Milliwatt: return (baseUnitValue) / 1e-3d; - case LuminosityUnit.Nanowatt: return (baseUnitValue) / 1e-9d; - case LuminosityUnit.Petawatt: return (baseUnitValue) / 1e15d; - case LuminosityUnit.Picowatt: return (baseUnitValue) / 1e-12d; - case LuminosityUnit.SolarLuminosity: return baseUnitValue / 3.846e26; - case LuminosityUnit.Terawatt: return (baseUnitValue) / 1e12d; - case LuminosityUnit.Watt: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + LuminosityUnit.Decawatt => (baseUnitValue) / 1e1d, + LuminosityUnit.Deciwatt => (baseUnitValue) / 1e-1d, + LuminosityUnit.Femtowatt => (baseUnitValue) / 1e-15d, + LuminosityUnit.Gigawatt => (baseUnitValue) / 1e9d, + LuminosityUnit.Kilowatt => (baseUnitValue) / 1e3d, + LuminosityUnit.Megawatt => (baseUnitValue) / 1e6d, + LuminosityUnit.Microwatt => (baseUnitValue) / 1e-6d, + LuminosityUnit.Milliwatt => (baseUnitValue) / 1e-3d, + LuminosityUnit.Nanowatt => (baseUnitValue) / 1e-9d, + LuminosityUnit.Petawatt => (baseUnitValue) / 1e15d, + LuminosityUnit.Picowatt => (baseUnitValue) / 1e-12d, + LuminosityUnit.SolarLuminosity => baseUnitValue / 3.846e26, + LuminosityUnit.Terawatt => (baseUnitValue) / 1e12d, + LuminosityUnit.Watt => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousFlux.g.cs index 801b11af71..e997bd00c7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -134,12 +134,11 @@ public LuminousFlux ToUnit(LuminousFluxUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case LuminousFluxUnit.Lumen: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + LuminousFluxUnit.Lumen => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(LuminousFluxUnit unit) @@ -149,12 +148,11 @@ private double GetValueAs(LuminousFluxUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case LuminousFluxUnit.Lumen: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + LuminousFluxUnit.Lumen => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousIntensity.g.cs index 55a7f4b904..d60dd535ef 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -134,12 +134,11 @@ public LuminousIntensity ToUnit(LuminousIntensityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case LuminousIntensityUnit.Candela: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + LuminousIntensityUnit.Candela => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(LuminousIntensityUnit unit) @@ -149,12 +148,11 @@ private double GetValueAs(LuminousIntensityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case LuminousIntensityUnit.Candela: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + LuminousIntensityUnit.Candela => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticField.g.cs index d38d1b548d..4467cfcf72 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticField.g.cs @@ -189,17 +189,16 @@ public MagneticField ToUnit(MagneticFieldUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case MagneticFieldUnit.Gauss: return _value/1e4; - case MagneticFieldUnit.Microtesla: return (_value) * 1e-6d; - case MagneticFieldUnit.Milligauss: return (_value/1e4) * 1e-3d; - case MagneticFieldUnit.Millitesla: return (_value) * 1e-3d; - case MagneticFieldUnit.Nanotesla: return (_value) * 1e-9d; - case MagneticFieldUnit.Tesla: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + MagneticFieldUnit.Gauss => _value/1e4, + MagneticFieldUnit.Microtesla => (_value) * 1e-6d, + MagneticFieldUnit.Milligauss => (_value/1e4) * 1e-3d, + MagneticFieldUnit.Millitesla => (_value) * 1e-3d, + MagneticFieldUnit.Nanotesla => (_value) * 1e-9d, + MagneticFieldUnit.Tesla => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(MagneticFieldUnit unit) @@ -209,17 +208,16 @@ private double GetValueAs(MagneticFieldUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case MagneticFieldUnit.Gauss: return baseUnitValue*1e4; - case MagneticFieldUnit.Microtesla: return (baseUnitValue) / 1e-6d; - case MagneticFieldUnit.Milligauss: return (baseUnitValue*1e4) / 1e-3d; - case MagneticFieldUnit.Millitesla: return (baseUnitValue) / 1e-3d; - case MagneticFieldUnit.Nanotesla: return (baseUnitValue) / 1e-9d; - case MagneticFieldUnit.Tesla: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + MagneticFieldUnit.Gauss => baseUnitValue*1e4, + MagneticFieldUnit.Microtesla => (baseUnitValue) / 1e-6d, + MagneticFieldUnit.Milligauss => (baseUnitValue*1e4) / 1e-3d, + MagneticFieldUnit.Millitesla => (baseUnitValue) / 1e-3d, + MagneticFieldUnit.Nanotesla => (baseUnitValue) / 1e-9d, + MagneticFieldUnit.Tesla => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticFlux.g.cs index b019231fb1..12984c48b4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -134,12 +134,11 @@ public MagneticFlux ToUnit(MagneticFluxUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case MagneticFluxUnit.Weber: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + MagneticFluxUnit.Weber => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(MagneticFluxUnit unit) @@ -149,12 +148,11 @@ private double GetValueAs(MagneticFluxUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case MagneticFluxUnit.Weber: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + MagneticFluxUnit.Weber => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Magnetization.g.cs index 591de5b52e..83d9df82dc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Magnetization.g.cs @@ -134,12 +134,11 @@ public Magnetization ToUnit(MagnetizationUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case MagnetizationUnit.AmperePerMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + MagnetizationUnit.AmperePerMeter => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(MagnetizationUnit unit) @@ -149,12 +148,11 @@ private double GetValueAs(MagnetizationUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case MagnetizationUnit.AmperePerMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + MagnetizationUnit.AmperePerMeter => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Mass.g.cs index d19c47fdd3..ff13bed16e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Mass.g.cs @@ -395,36 +395,35 @@ public Mass ToUnit(MassUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case MassUnit.Centigram: return (_value/1e3) * 1e-2d; - case MassUnit.Decagram: return (_value/1e3) * 1e1d; - case MassUnit.Decigram: return (_value/1e3) * 1e-1d; - case MassUnit.EarthMass: return _value * 5.9722E+24; - case MassUnit.Grain: return _value/15432.358352941431; - case MassUnit.Gram: return _value/1e3; - case MassUnit.Hectogram: return (_value/1e3) * 1e2d; - case MassUnit.Kilogram: return (_value/1e3) * 1e3d; - case MassUnit.Kilopound: return (_value*0.45359237) * 1e3d; - case MassUnit.Kilotonne: return (_value*1e3) * 1e3d; - case MassUnit.LongHundredweight: return _value/0.01968413055222121; - case MassUnit.LongTon: return _value*1.0160469088e3; - case MassUnit.Megapound: return (_value*0.45359237) * 1e6d; - case MassUnit.Megatonne: return (_value*1e3) * 1e6d; - case MassUnit.Microgram: return (_value/1e3) * 1e-6d; - case MassUnit.Milligram: return (_value/1e3) * 1e-3d; - case MassUnit.Nanogram: return (_value/1e3) * 1e-9d; - case MassUnit.Ounce: return _value/35.2739619; - case MassUnit.Pound: return _value*0.45359237; - case MassUnit.ShortHundredweight: return _value/0.022046226218487758; - case MassUnit.ShortTon: return _value*9.0718474e2; - case MassUnit.Slug: return _value/6.852176556196105e-2; - case MassUnit.SolarMass: return _value * 1.98947e30; - case MassUnit.Stone: return _value/0.1574731728702698; - case MassUnit.Tonne: return _value*1e3; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + MassUnit.Centigram => (_value/1e3) * 1e-2d, + MassUnit.Decagram => (_value/1e3) * 1e1d, + MassUnit.Decigram => (_value/1e3) * 1e-1d, + MassUnit.EarthMass => _value * 5.9722E+24, + MassUnit.Grain => _value/15432.358352941431, + MassUnit.Gram => _value/1e3, + MassUnit.Hectogram => (_value/1e3) * 1e2d, + MassUnit.Kilogram => (_value/1e3) * 1e3d, + MassUnit.Kilopound => (_value*0.45359237) * 1e3d, + MassUnit.Kilotonne => (_value*1e3) * 1e3d, + MassUnit.LongHundredweight => _value/0.01968413055222121, + MassUnit.LongTon => _value*1.0160469088e3, + MassUnit.Megapound => (_value*0.45359237) * 1e6d, + MassUnit.Megatonne => (_value*1e3) * 1e6d, + MassUnit.Microgram => (_value/1e3) * 1e-6d, + MassUnit.Milligram => (_value/1e3) * 1e-3d, + MassUnit.Nanogram => (_value/1e3) * 1e-9d, + MassUnit.Ounce => _value/35.2739619, + MassUnit.Pound => _value*0.45359237, + MassUnit.ShortHundredweight => _value/0.022046226218487758, + MassUnit.ShortTon => _value*9.0718474e2, + MassUnit.Slug => _value/6.852176556196105e-2, + MassUnit.SolarMass => _value * 1.98947e30, + MassUnit.Stone => _value/0.1574731728702698, + MassUnit.Tonne => _value*1e3, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(MassUnit unit) @@ -434,36 +433,35 @@ private double GetValueAs(MassUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case MassUnit.Centigram: return (baseUnitValue*1e3) / 1e-2d; - case MassUnit.Decagram: return (baseUnitValue*1e3) / 1e1d; - case MassUnit.Decigram: return (baseUnitValue*1e3) / 1e-1d; - case MassUnit.EarthMass: return baseUnitValue / 5.9722E+24; - case MassUnit.Grain: return baseUnitValue*15432.358352941431; - case MassUnit.Gram: return baseUnitValue*1e3; - case MassUnit.Hectogram: return (baseUnitValue*1e3) / 1e2d; - case MassUnit.Kilogram: return (baseUnitValue*1e3) / 1e3d; - case MassUnit.Kilopound: return (baseUnitValue/0.45359237) / 1e3d; - case MassUnit.Kilotonne: return (baseUnitValue/1e3) / 1e3d; - case MassUnit.LongHundredweight: return baseUnitValue*0.01968413055222121; - case MassUnit.LongTon: return baseUnitValue/1.0160469088e3; - case MassUnit.Megapound: return (baseUnitValue/0.45359237) / 1e6d; - case MassUnit.Megatonne: return (baseUnitValue/1e3) / 1e6d; - case MassUnit.Microgram: return (baseUnitValue*1e3) / 1e-6d; - case MassUnit.Milligram: return (baseUnitValue*1e3) / 1e-3d; - case MassUnit.Nanogram: return (baseUnitValue*1e3) / 1e-9d; - case MassUnit.Ounce: return baseUnitValue*35.2739619; - case MassUnit.Pound: return baseUnitValue/0.45359237; - case MassUnit.ShortHundredweight: return baseUnitValue*0.022046226218487758; - case MassUnit.ShortTon: return baseUnitValue/9.0718474e2; - case MassUnit.Slug: return baseUnitValue*6.852176556196105e-2; - case MassUnit.SolarMass: return baseUnitValue / 1.98947e30; - case MassUnit.Stone: return baseUnitValue*0.1574731728702698; - case MassUnit.Tonne: return baseUnitValue/1e3; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + MassUnit.Centigram => (baseUnitValue*1e3) / 1e-2d, + MassUnit.Decagram => (baseUnitValue*1e3) / 1e1d, + MassUnit.Decigram => (baseUnitValue*1e3) / 1e-1d, + MassUnit.EarthMass => baseUnitValue / 5.9722E+24, + MassUnit.Grain => baseUnitValue*15432.358352941431, + MassUnit.Gram => baseUnitValue*1e3, + MassUnit.Hectogram => (baseUnitValue*1e3) / 1e2d, + MassUnit.Kilogram => (baseUnitValue*1e3) / 1e3d, + MassUnit.Kilopound => (baseUnitValue/0.45359237) / 1e3d, + MassUnit.Kilotonne => (baseUnitValue/1e3) / 1e3d, + MassUnit.LongHundredweight => baseUnitValue*0.01968413055222121, + MassUnit.LongTon => baseUnitValue/1.0160469088e3, + MassUnit.Megapound => (baseUnitValue/0.45359237) / 1e6d, + MassUnit.Megatonne => (baseUnitValue/1e3) / 1e6d, + MassUnit.Microgram => (baseUnitValue*1e3) / 1e-6d, + MassUnit.Milligram => (baseUnitValue*1e3) / 1e-3d, + MassUnit.Nanogram => (baseUnitValue*1e3) / 1e-9d, + MassUnit.Ounce => baseUnitValue*35.2739619, + MassUnit.Pound => baseUnitValue/0.45359237, + MassUnit.ShortHundredweight => baseUnitValue*0.022046226218487758, + MassUnit.ShortTon => baseUnitValue/9.0718474e2, + MassUnit.Slug => baseUnitValue*6.852176556196105e-2, + MassUnit.SolarMass => baseUnitValue / 1.98947e30, + MassUnit.Stone => baseUnitValue*0.1574731728702698, + MassUnit.Tonne => baseUnitValue/1e3, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassConcentration.g.cs index 5a8b934154..885d556984 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassConcentration.g.cs @@ -662,60 +662,59 @@ public MassConcentration ToUnit(MassConcentrationUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case MassConcentrationUnit.CentigramPerDeciliter: return (_value/1e-1) * 1e-2d; - case MassConcentrationUnit.CentigramPerLiter: return (_value) * 1e-2d; - case MassConcentrationUnit.CentigramPerMicroliter: return (_value/1e-6) * 1e-2d; - case MassConcentrationUnit.CentigramPerMilliliter: return (_value/1e-3) * 1e-2d; - case MassConcentrationUnit.DecigramPerDeciliter: return (_value/1e-1) * 1e-1d; - case MassConcentrationUnit.DecigramPerLiter: return (_value) * 1e-1d; - case MassConcentrationUnit.DecigramPerMicroliter: return (_value/1e-6) * 1e-1d; - case MassConcentrationUnit.DecigramPerMilliliter: return (_value/1e-3) * 1e-1d; - case MassConcentrationUnit.GramPerCubicCentimeter: return _value/1e-3; - case MassConcentrationUnit.GramPerCubicMeter: return _value/1e3; - case MassConcentrationUnit.GramPerCubicMillimeter: return _value/1e-6; - case MassConcentrationUnit.GramPerDeciliter: return _value/1e-1; - case MassConcentrationUnit.GramPerLiter: return _value; - case MassConcentrationUnit.GramPerMicroliter: return _value/1e-6; - case MassConcentrationUnit.GramPerMilliliter: return _value/1e-3; - case MassConcentrationUnit.KilogramPerCubicCentimeter: return (_value/1e-3) * 1e3d; - case MassConcentrationUnit.KilogramPerCubicMeter: return (_value/1e3) * 1e3d; - case MassConcentrationUnit.KilogramPerCubicMillimeter: return (_value/1e-6) * 1e3d; - case MassConcentrationUnit.KilogramPerLiter: return (_value) * 1e3d; - case MassConcentrationUnit.KilopoundPerCubicFoot: return (_value/0.062427961) * 1e3d; - case MassConcentrationUnit.KilopoundPerCubicInch: return (_value/3.6127298147753e-5) * 1e3d; - case MassConcentrationUnit.MicrogramPerCubicMeter: return (_value/1e3) * 1e-6d; - case MassConcentrationUnit.MicrogramPerDeciliter: return (_value/1e-1) * 1e-6d; - case MassConcentrationUnit.MicrogramPerLiter: return (_value) * 1e-6d; - case MassConcentrationUnit.MicrogramPerMicroliter: return (_value/1e-6) * 1e-6d; - case MassConcentrationUnit.MicrogramPerMilliliter: return (_value/1e-3) * 1e-6d; - case MassConcentrationUnit.MilligramPerCubicMeter: return (_value/1e3) * 1e-3d; - case MassConcentrationUnit.MilligramPerDeciliter: return (_value/1e-1) * 1e-3d; - case MassConcentrationUnit.MilligramPerLiter: return (_value) * 1e-3d; - case MassConcentrationUnit.MilligramPerMicroliter: return (_value/1e-6) * 1e-3d; - case MassConcentrationUnit.MilligramPerMilliliter: return (_value/1e-3) * 1e-3d; - case MassConcentrationUnit.NanogramPerDeciliter: return (_value/1e-1) * 1e-9d; - case MassConcentrationUnit.NanogramPerLiter: return (_value) * 1e-9d; - case MassConcentrationUnit.NanogramPerMicroliter: return (_value/1e-6) * 1e-9d; - case MassConcentrationUnit.NanogramPerMilliliter: return (_value/1e-3) * 1e-9d; - case MassConcentrationUnit.OuncePerImperialGallon: return _value/0.1603586720609; - case MassConcentrationUnit.OuncePerUSGallon: return _value/0.1335264711843; - case MassConcentrationUnit.PicogramPerDeciliter: return (_value/1e-1) * 1e-12d; - case MassConcentrationUnit.PicogramPerLiter: return (_value) * 1e-12d; - case MassConcentrationUnit.PicogramPerMicroliter: return (_value/1e-6) * 1e-12d; - case MassConcentrationUnit.PicogramPerMilliliter: return (_value/1e-3) * 1e-12d; - case MassConcentrationUnit.PoundPerCubicFoot: return _value/0.062427961; - case MassConcentrationUnit.PoundPerCubicInch: return _value/3.6127298147753e-5; - case MassConcentrationUnit.PoundPerImperialGallon: return _value*9.9776398e1; - case MassConcentrationUnit.PoundPerUSGallon: return _value*1.19826427e2; - case MassConcentrationUnit.SlugPerCubicFoot: return _value*515.378818; - case MassConcentrationUnit.TonnePerCubicCentimeter: return _value/1e-9; - case MassConcentrationUnit.TonnePerCubicMeter: return _value/0.001; - case MassConcentrationUnit.TonnePerCubicMillimeter: return _value/1e-12; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + MassConcentrationUnit.CentigramPerDeciliter => (_value/1e-1) * 1e-2d, + MassConcentrationUnit.CentigramPerLiter => (_value) * 1e-2d, + MassConcentrationUnit.CentigramPerMicroliter => (_value/1e-6) * 1e-2d, + MassConcentrationUnit.CentigramPerMilliliter => (_value/1e-3) * 1e-2d, + MassConcentrationUnit.DecigramPerDeciliter => (_value/1e-1) * 1e-1d, + MassConcentrationUnit.DecigramPerLiter => (_value) * 1e-1d, + MassConcentrationUnit.DecigramPerMicroliter => (_value/1e-6) * 1e-1d, + MassConcentrationUnit.DecigramPerMilliliter => (_value/1e-3) * 1e-1d, + MassConcentrationUnit.GramPerCubicCentimeter => _value/1e-3, + MassConcentrationUnit.GramPerCubicMeter => _value/1e3, + MassConcentrationUnit.GramPerCubicMillimeter => _value/1e-6, + MassConcentrationUnit.GramPerDeciliter => _value/1e-1, + MassConcentrationUnit.GramPerLiter => _value, + MassConcentrationUnit.GramPerMicroliter => _value/1e-6, + MassConcentrationUnit.GramPerMilliliter => _value/1e-3, + MassConcentrationUnit.KilogramPerCubicCentimeter => (_value/1e-3) * 1e3d, + MassConcentrationUnit.KilogramPerCubicMeter => (_value/1e3) * 1e3d, + MassConcentrationUnit.KilogramPerCubicMillimeter => (_value/1e-6) * 1e3d, + MassConcentrationUnit.KilogramPerLiter => (_value) * 1e3d, + MassConcentrationUnit.KilopoundPerCubicFoot => (_value/0.062427961) * 1e3d, + MassConcentrationUnit.KilopoundPerCubicInch => (_value/3.6127298147753e-5) * 1e3d, + MassConcentrationUnit.MicrogramPerCubicMeter => (_value/1e3) * 1e-6d, + MassConcentrationUnit.MicrogramPerDeciliter => (_value/1e-1) * 1e-6d, + MassConcentrationUnit.MicrogramPerLiter => (_value) * 1e-6d, + MassConcentrationUnit.MicrogramPerMicroliter => (_value/1e-6) * 1e-6d, + MassConcentrationUnit.MicrogramPerMilliliter => (_value/1e-3) * 1e-6d, + MassConcentrationUnit.MilligramPerCubicMeter => (_value/1e3) * 1e-3d, + MassConcentrationUnit.MilligramPerDeciliter => (_value/1e-1) * 1e-3d, + MassConcentrationUnit.MilligramPerLiter => (_value) * 1e-3d, + MassConcentrationUnit.MilligramPerMicroliter => (_value/1e-6) * 1e-3d, + MassConcentrationUnit.MilligramPerMilliliter => (_value/1e-3) * 1e-3d, + MassConcentrationUnit.NanogramPerDeciliter => (_value/1e-1) * 1e-9d, + MassConcentrationUnit.NanogramPerLiter => (_value) * 1e-9d, + MassConcentrationUnit.NanogramPerMicroliter => (_value/1e-6) * 1e-9d, + MassConcentrationUnit.NanogramPerMilliliter => (_value/1e-3) * 1e-9d, + MassConcentrationUnit.OuncePerImperialGallon => _value/0.1603586720609, + MassConcentrationUnit.OuncePerUSGallon => _value/0.1335264711843, + MassConcentrationUnit.PicogramPerDeciliter => (_value/1e-1) * 1e-12d, + MassConcentrationUnit.PicogramPerLiter => (_value) * 1e-12d, + MassConcentrationUnit.PicogramPerMicroliter => (_value/1e-6) * 1e-12d, + MassConcentrationUnit.PicogramPerMilliliter => (_value/1e-3) * 1e-12d, + MassConcentrationUnit.PoundPerCubicFoot => _value/0.062427961, + MassConcentrationUnit.PoundPerCubicInch => _value/3.6127298147753e-5, + MassConcentrationUnit.PoundPerImperialGallon => _value*9.9776398e1, + MassConcentrationUnit.PoundPerUSGallon => _value*1.19826427e2, + MassConcentrationUnit.SlugPerCubicFoot => _value*515.378818, + MassConcentrationUnit.TonnePerCubicCentimeter => _value/1e-9, + MassConcentrationUnit.TonnePerCubicMeter => _value/0.001, + MassConcentrationUnit.TonnePerCubicMillimeter => _value/1e-12, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(MassConcentrationUnit unit) @@ -725,60 +724,59 @@ private double GetValueAs(MassConcentrationUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case MassConcentrationUnit.CentigramPerDeciliter: return (baseUnitValue*1e-1) / 1e-2d; - case MassConcentrationUnit.CentigramPerLiter: return (baseUnitValue) / 1e-2d; - case MassConcentrationUnit.CentigramPerMicroliter: return (baseUnitValue*1e-6) / 1e-2d; - case MassConcentrationUnit.CentigramPerMilliliter: return (baseUnitValue*1e-3) / 1e-2d; - case MassConcentrationUnit.DecigramPerDeciliter: return (baseUnitValue*1e-1) / 1e-1d; - case MassConcentrationUnit.DecigramPerLiter: return (baseUnitValue) / 1e-1d; - case MassConcentrationUnit.DecigramPerMicroliter: return (baseUnitValue*1e-6) / 1e-1d; - case MassConcentrationUnit.DecigramPerMilliliter: return (baseUnitValue*1e-3) / 1e-1d; - case MassConcentrationUnit.GramPerCubicCentimeter: return baseUnitValue*1e-3; - case MassConcentrationUnit.GramPerCubicMeter: return baseUnitValue*1e3; - case MassConcentrationUnit.GramPerCubicMillimeter: return baseUnitValue*1e-6; - case MassConcentrationUnit.GramPerDeciliter: return baseUnitValue*1e-1; - case MassConcentrationUnit.GramPerLiter: return baseUnitValue; - case MassConcentrationUnit.GramPerMicroliter: return baseUnitValue*1e-6; - case MassConcentrationUnit.GramPerMilliliter: return baseUnitValue*1e-3; - case MassConcentrationUnit.KilogramPerCubicCentimeter: return (baseUnitValue*1e-3) / 1e3d; - case MassConcentrationUnit.KilogramPerCubicMeter: return (baseUnitValue*1e3) / 1e3d; - case MassConcentrationUnit.KilogramPerCubicMillimeter: return (baseUnitValue*1e-6) / 1e3d; - case MassConcentrationUnit.KilogramPerLiter: return (baseUnitValue) / 1e3d; - case MassConcentrationUnit.KilopoundPerCubicFoot: return (baseUnitValue*0.062427961) / 1e3d; - case MassConcentrationUnit.KilopoundPerCubicInch: return (baseUnitValue*3.6127298147753e-5) / 1e3d; - case MassConcentrationUnit.MicrogramPerCubicMeter: return (baseUnitValue*1e3) / 1e-6d; - case MassConcentrationUnit.MicrogramPerDeciliter: return (baseUnitValue*1e-1) / 1e-6d; - case MassConcentrationUnit.MicrogramPerLiter: return (baseUnitValue) / 1e-6d; - case MassConcentrationUnit.MicrogramPerMicroliter: return (baseUnitValue*1e-6) / 1e-6d; - case MassConcentrationUnit.MicrogramPerMilliliter: return (baseUnitValue*1e-3) / 1e-6d; - case MassConcentrationUnit.MilligramPerCubicMeter: return (baseUnitValue*1e3) / 1e-3d; - case MassConcentrationUnit.MilligramPerDeciliter: return (baseUnitValue*1e-1) / 1e-3d; - case MassConcentrationUnit.MilligramPerLiter: return (baseUnitValue) / 1e-3d; - case MassConcentrationUnit.MilligramPerMicroliter: return (baseUnitValue*1e-6) / 1e-3d; - case MassConcentrationUnit.MilligramPerMilliliter: return (baseUnitValue*1e-3) / 1e-3d; - case MassConcentrationUnit.NanogramPerDeciliter: return (baseUnitValue*1e-1) / 1e-9d; - case MassConcentrationUnit.NanogramPerLiter: return (baseUnitValue) / 1e-9d; - case MassConcentrationUnit.NanogramPerMicroliter: return (baseUnitValue*1e-6) / 1e-9d; - case MassConcentrationUnit.NanogramPerMilliliter: return (baseUnitValue*1e-3) / 1e-9d; - case MassConcentrationUnit.OuncePerImperialGallon: return baseUnitValue*0.1603586720609; - case MassConcentrationUnit.OuncePerUSGallon: return baseUnitValue*0.1335264711843; - case MassConcentrationUnit.PicogramPerDeciliter: return (baseUnitValue*1e-1) / 1e-12d; - case MassConcentrationUnit.PicogramPerLiter: return (baseUnitValue) / 1e-12d; - case MassConcentrationUnit.PicogramPerMicroliter: return (baseUnitValue*1e-6) / 1e-12d; - case MassConcentrationUnit.PicogramPerMilliliter: return (baseUnitValue*1e-3) / 1e-12d; - case MassConcentrationUnit.PoundPerCubicFoot: return baseUnitValue*0.062427961; - case MassConcentrationUnit.PoundPerCubicInch: return baseUnitValue*3.6127298147753e-5; - case MassConcentrationUnit.PoundPerImperialGallon: return baseUnitValue/9.9776398e1; - case MassConcentrationUnit.PoundPerUSGallon: return baseUnitValue/1.19826427e2; - case MassConcentrationUnit.SlugPerCubicFoot: return baseUnitValue*0.00194032033; - case MassConcentrationUnit.TonnePerCubicCentimeter: return baseUnitValue*1e-9; - case MassConcentrationUnit.TonnePerCubicMeter: return baseUnitValue*0.001; - case MassConcentrationUnit.TonnePerCubicMillimeter: return baseUnitValue*1e-12; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + MassConcentrationUnit.CentigramPerDeciliter => (baseUnitValue*1e-1) / 1e-2d, + MassConcentrationUnit.CentigramPerLiter => (baseUnitValue) / 1e-2d, + MassConcentrationUnit.CentigramPerMicroliter => (baseUnitValue*1e-6) / 1e-2d, + MassConcentrationUnit.CentigramPerMilliliter => (baseUnitValue*1e-3) / 1e-2d, + MassConcentrationUnit.DecigramPerDeciliter => (baseUnitValue*1e-1) / 1e-1d, + MassConcentrationUnit.DecigramPerLiter => (baseUnitValue) / 1e-1d, + MassConcentrationUnit.DecigramPerMicroliter => (baseUnitValue*1e-6) / 1e-1d, + MassConcentrationUnit.DecigramPerMilliliter => (baseUnitValue*1e-3) / 1e-1d, + MassConcentrationUnit.GramPerCubicCentimeter => baseUnitValue*1e-3, + MassConcentrationUnit.GramPerCubicMeter => baseUnitValue*1e3, + MassConcentrationUnit.GramPerCubicMillimeter => baseUnitValue*1e-6, + MassConcentrationUnit.GramPerDeciliter => baseUnitValue*1e-1, + MassConcentrationUnit.GramPerLiter => baseUnitValue, + MassConcentrationUnit.GramPerMicroliter => baseUnitValue*1e-6, + MassConcentrationUnit.GramPerMilliliter => baseUnitValue*1e-3, + MassConcentrationUnit.KilogramPerCubicCentimeter => (baseUnitValue*1e-3) / 1e3d, + MassConcentrationUnit.KilogramPerCubicMeter => (baseUnitValue*1e3) / 1e3d, + MassConcentrationUnit.KilogramPerCubicMillimeter => (baseUnitValue*1e-6) / 1e3d, + MassConcentrationUnit.KilogramPerLiter => (baseUnitValue) / 1e3d, + MassConcentrationUnit.KilopoundPerCubicFoot => (baseUnitValue*0.062427961) / 1e3d, + MassConcentrationUnit.KilopoundPerCubicInch => (baseUnitValue*3.6127298147753e-5) / 1e3d, + MassConcentrationUnit.MicrogramPerCubicMeter => (baseUnitValue*1e3) / 1e-6d, + MassConcentrationUnit.MicrogramPerDeciliter => (baseUnitValue*1e-1) / 1e-6d, + MassConcentrationUnit.MicrogramPerLiter => (baseUnitValue) / 1e-6d, + MassConcentrationUnit.MicrogramPerMicroliter => (baseUnitValue*1e-6) / 1e-6d, + MassConcentrationUnit.MicrogramPerMilliliter => (baseUnitValue*1e-3) / 1e-6d, + MassConcentrationUnit.MilligramPerCubicMeter => (baseUnitValue*1e3) / 1e-3d, + MassConcentrationUnit.MilligramPerDeciliter => (baseUnitValue*1e-1) / 1e-3d, + MassConcentrationUnit.MilligramPerLiter => (baseUnitValue) / 1e-3d, + MassConcentrationUnit.MilligramPerMicroliter => (baseUnitValue*1e-6) / 1e-3d, + MassConcentrationUnit.MilligramPerMilliliter => (baseUnitValue*1e-3) / 1e-3d, + MassConcentrationUnit.NanogramPerDeciliter => (baseUnitValue*1e-1) / 1e-9d, + MassConcentrationUnit.NanogramPerLiter => (baseUnitValue) / 1e-9d, + MassConcentrationUnit.NanogramPerMicroliter => (baseUnitValue*1e-6) / 1e-9d, + MassConcentrationUnit.NanogramPerMilliliter => (baseUnitValue*1e-3) / 1e-9d, + MassConcentrationUnit.OuncePerImperialGallon => baseUnitValue*0.1603586720609, + MassConcentrationUnit.OuncePerUSGallon => baseUnitValue*0.1335264711843, + MassConcentrationUnit.PicogramPerDeciliter => (baseUnitValue*1e-1) / 1e-12d, + MassConcentrationUnit.PicogramPerLiter => (baseUnitValue) / 1e-12d, + MassConcentrationUnit.PicogramPerMicroliter => (baseUnitValue*1e-6) / 1e-12d, + MassConcentrationUnit.PicogramPerMilliliter => (baseUnitValue*1e-3) / 1e-12d, + MassConcentrationUnit.PoundPerCubicFoot => baseUnitValue*0.062427961, + MassConcentrationUnit.PoundPerCubicInch => baseUnitValue*3.6127298147753e-5, + MassConcentrationUnit.PoundPerImperialGallon => baseUnitValue/9.9776398e1, + MassConcentrationUnit.PoundPerUSGallon => baseUnitValue/1.19826427e2, + MassConcentrationUnit.SlugPerCubicFoot => baseUnitValue*0.00194032033, + MassConcentrationUnit.TonnePerCubicCentimeter => baseUnitValue*1e-9, + MassConcentrationUnit.TonnePerCubicMeter => baseUnitValue*0.001, + MassConcentrationUnit.TonnePerCubicMillimeter => baseUnitValue*1e-12, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlow.g.cs index 61bb45037c..e61c3b644b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlow.g.cs @@ -483,44 +483,43 @@ public MassFlow ToUnit(MassFlowUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case MassFlowUnit.CentigramPerDay: return (_value/86400) * 1e-2d; - case MassFlowUnit.CentigramPerSecond: return (_value) * 1e-2d; - case MassFlowUnit.DecagramPerDay: return (_value/86400) * 1e1d; - case MassFlowUnit.DecagramPerSecond: return (_value) * 1e1d; - case MassFlowUnit.DecigramPerDay: return (_value/86400) * 1e-1d; - case MassFlowUnit.DecigramPerSecond: return (_value) * 1e-1d; - case MassFlowUnit.GramPerDay: return _value/86400; - case MassFlowUnit.GramPerHour: return _value/3600; - case MassFlowUnit.GramPerSecond: return _value; - case MassFlowUnit.HectogramPerDay: return (_value/86400) * 1e2d; - case MassFlowUnit.HectogramPerSecond: return (_value) * 1e2d; - case MassFlowUnit.KilogramPerDay: return (_value/86400) * 1e3d; - case MassFlowUnit.KilogramPerHour: return _value/3.6; - case MassFlowUnit.KilogramPerMinute: return _value/0.06; - case MassFlowUnit.KilogramPerSecond: return (_value) * 1e3d; - case MassFlowUnit.MegagramPerDay: return (_value/86400) * 1e6d; - case MassFlowUnit.MegapoundPerDay: return (_value/190.47936) * 1e6d; - case MassFlowUnit.MegapoundPerHour: return (_value/7.93664) * 1e6d; - case MassFlowUnit.MegapoundPerMinute: return (_value/0.132277) * 1e6d; - case MassFlowUnit.MegapoundPerSecond: return (_value * 453.59237) * 1e6d; - case MassFlowUnit.MicrogramPerDay: return (_value/86400) * 1e-6d; - case MassFlowUnit.MicrogramPerSecond: return (_value) * 1e-6d; - case MassFlowUnit.MilligramPerDay: return (_value/86400) * 1e-3d; - case MassFlowUnit.MilligramPerSecond: return (_value) * 1e-3d; - case MassFlowUnit.NanogramPerDay: return (_value/86400) * 1e-9d; - case MassFlowUnit.NanogramPerSecond: return (_value) * 1e-9d; - case MassFlowUnit.PoundPerDay: return _value/190.47936; - case MassFlowUnit.PoundPerHour: return _value/7.93664; - case MassFlowUnit.PoundPerMinute: return _value/0.132277; - case MassFlowUnit.PoundPerSecond: return _value * 453.59237; - case MassFlowUnit.ShortTonPerHour: return _value*251.9957611; - case MassFlowUnit.TonnePerDay: return _value/0.0864000; - case MassFlowUnit.TonnePerHour: return 1000*_value/3.6; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + MassFlowUnit.CentigramPerDay => (_value/86400) * 1e-2d, + MassFlowUnit.CentigramPerSecond => (_value) * 1e-2d, + MassFlowUnit.DecagramPerDay => (_value/86400) * 1e1d, + MassFlowUnit.DecagramPerSecond => (_value) * 1e1d, + MassFlowUnit.DecigramPerDay => (_value/86400) * 1e-1d, + MassFlowUnit.DecigramPerSecond => (_value) * 1e-1d, + MassFlowUnit.GramPerDay => _value/86400, + MassFlowUnit.GramPerHour => _value/3600, + MassFlowUnit.GramPerSecond => _value, + MassFlowUnit.HectogramPerDay => (_value/86400) * 1e2d, + MassFlowUnit.HectogramPerSecond => (_value) * 1e2d, + MassFlowUnit.KilogramPerDay => (_value/86400) * 1e3d, + MassFlowUnit.KilogramPerHour => _value/3.6, + MassFlowUnit.KilogramPerMinute => _value/0.06, + MassFlowUnit.KilogramPerSecond => (_value) * 1e3d, + MassFlowUnit.MegagramPerDay => (_value/86400) * 1e6d, + MassFlowUnit.MegapoundPerDay => (_value/190.47936) * 1e6d, + MassFlowUnit.MegapoundPerHour => (_value/7.93664) * 1e6d, + MassFlowUnit.MegapoundPerMinute => (_value/0.132277) * 1e6d, + MassFlowUnit.MegapoundPerSecond => (_value * 453.59237) * 1e6d, + MassFlowUnit.MicrogramPerDay => (_value/86400) * 1e-6d, + MassFlowUnit.MicrogramPerSecond => (_value) * 1e-6d, + MassFlowUnit.MilligramPerDay => (_value/86400) * 1e-3d, + MassFlowUnit.MilligramPerSecond => (_value) * 1e-3d, + MassFlowUnit.NanogramPerDay => (_value/86400) * 1e-9d, + MassFlowUnit.NanogramPerSecond => (_value) * 1e-9d, + MassFlowUnit.PoundPerDay => _value/190.47936, + MassFlowUnit.PoundPerHour => _value/7.93664, + MassFlowUnit.PoundPerMinute => _value/0.132277, + MassFlowUnit.PoundPerSecond => _value * 453.59237, + MassFlowUnit.ShortTonPerHour => _value*251.9957611, + MassFlowUnit.TonnePerDay => _value/0.0864000, + MassFlowUnit.TonnePerHour => 1000*_value/3.6, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(MassFlowUnit unit) @@ -530,44 +529,43 @@ private double GetValueAs(MassFlowUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case MassFlowUnit.CentigramPerDay: return (baseUnitValue*86400) / 1e-2d; - case MassFlowUnit.CentigramPerSecond: return (baseUnitValue) / 1e-2d; - case MassFlowUnit.DecagramPerDay: return (baseUnitValue*86400) / 1e1d; - case MassFlowUnit.DecagramPerSecond: return (baseUnitValue) / 1e1d; - case MassFlowUnit.DecigramPerDay: return (baseUnitValue*86400) / 1e-1d; - case MassFlowUnit.DecigramPerSecond: return (baseUnitValue) / 1e-1d; - case MassFlowUnit.GramPerDay: return baseUnitValue*86400; - case MassFlowUnit.GramPerHour: return baseUnitValue*3600; - case MassFlowUnit.GramPerSecond: return baseUnitValue; - case MassFlowUnit.HectogramPerDay: return (baseUnitValue*86400) / 1e2d; - case MassFlowUnit.HectogramPerSecond: return (baseUnitValue) / 1e2d; - case MassFlowUnit.KilogramPerDay: return (baseUnitValue*86400) / 1e3d; - case MassFlowUnit.KilogramPerHour: return baseUnitValue*3.6; - case MassFlowUnit.KilogramPerMinute: return baseUnitValue*0.06; - case MassFlowUnit.KilogramPerSecond: return (baseUnitValue) / 1e3d; - case MassFlowUnit.MegagramPerDay: return (baseUnitValue*86400) / 1e6d; - case MassFlowUnit.MegapoundPerDay: return (baseUnitValue*190.47936) / 1e6d; - case MassFlowUnit.MegapoundPerHour: return (baseUnitValue*7.93664) / 1e6d; - case MassFlowUnit.MegapoundPerMinute: return (baseUnitValue*0.132277) / 1e6d; - case MassFlowUnit.MegapoundPerSecond: return (baseUnitValue / 453.59237) / 1e6d; - case MassFlowUnit.MicrogramPerDay: return (baseUnitValue*86400) / 1e-6d; - case MassFlowUnit.MicrogramPerSecond: return (baseUnitValue) / 1e-6d; - case MassFlowUnit.MilligramPerDay: return (baseUnitValue*86400) / 1e-3d; - case MassFlowUnit.MilligramPerSecond: return (baseUnitValue) / 1e-3d; - case MassFlowUnit.NanogramPerDay: return (baseUnitValue*86400) / 1e-9d; - case MassFlowUnit.NanogramPerSecond: return (baseUnitValue) / 1e-9d; - case MassFlowUnit.PoundPerDay: return baseUnitValue*190.47936; - case MassFlowUnit.PoundPerHour: return baseUnitValue*7.93664; - case MassFlowUnit.PoundPerMinute: return baseUnitValue*0.132277; - case MassFlowUnit.PoundPerSecond: return baseUnitValue / 453.59237; - case MassFlowUnit.ShortTonPerHour: return baseUnitValue/251.9957611; - case MassFlowUnit.TonnePerDay: return baseUnitValue*0.0864000; - case MassFlowUnit.TonnePerHour: return baseUnitValue*3.6/1000; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + MassFlowUnit.CentigramPerDay => (baseUnitValue*86400) / 1e-2d, + MassFlowUnit.CentigramPerSecond => (baseUnitValue) / 1e-2d, + MassFlowUnit.DecagramPerDay => (baseUnitValue*86400) / 1e1d, + MassFlowUnit.DecagramPerSecond => (baseUnitValue) / 1e1d, + MassFlowUnit.DecigramPerDay => (baseUnitValue*86400) / 1e-1d, + MassFlowUnit.DecigramPerSecond => (baseUnitValue) / 1e-1d, + MassFlowUnit.GramPerDay => baseUnitValue*86400, + MassFlowUnit.GramPerHour => baseUnitValue*3600, + MassFlowUnit.GramPerSecond => baseUnitValue, + MassFlowUnit.HectogramPerDay => (baseUnitValue*86400) / 1e2d, + MassFlowUnit.HectogramPerSecond => (baseUnitValue) / 1e2d, + MassFlowUnit.KilogramPerDay => (baseUnitValue*86400) / 1e3d, + MassFlowUnit.KilogramPerHour => baseUnitValue*3.6, + MassFlowUnit.KilogramPerMinute => baseUnitValue*0.06, + MassFlowUnit.KilogramPerSecond => (baseUnitValue) / 1e3d, + MassFlowUnit.MegagramPerDay => (baseUnitValue*86400) / 1e6d, + MassFlowUnit.MegapoundPerDay => (baseUnitValue*190.47936) / 1e6d, + MassFlowUnit.MegapoundPerHour => (baseUnitValue*7.93664) / 1e6d, + MassFlowUnit.MegapoundPerMinute => (baseUnitValue*0.132277) / 1e6d, + MassFlowUnit.MegapoundPerSecond => (baseUnitValue / 453.59237) / 1e6d, + MassFlowUnit.MicrogramPerDay => (baseUnitValue*86400) / 1e-6d, + MassFlowUnit.MicrogramPerSecond => (baseUnitValue) / 1e-6d, + MassFlowUnit.MilligramPerDay => (baseUnitValue*86400) / 1e-3d, + MassFlowUnit.MilligramPerSecond => (baseUnitValue) / 1e-3d, + MassFlowUnit.NanogramPerDay => (baseUnitValue*86400) / 1e-9d, + MassFlowUnit.NanogramPerSecond => (baseUnitValue) / 1e-9d, + MassFlowUnit.PoundPerDay => baseUnitValue*190.47936, + MassFlowUnit.PoundPerHour => baseUnitValue*7.93664, + MassFlowUnit.PoundPerMinute => baseUnitValue*0.132277, + MassFlowUnit.PoundPerSecond => baseUnitValue / 453.59237, + MassFlowUnit.ShortTonPerHour => baseUnitValue/251.9957611, + MassFlowUnit.TonnePerDay => baseUnitValue*0.0864000, + MassFlowUnit.TonnePerHour => baseUnitValue*3.6/1000, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlux.g.cs index 5bc7092e15..65c6a284ff 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlux.g.cs @@ -252,23 +252,22 @@ public MassFlux ToUnit(MassFluxUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case MassFluxUnit.GramPerHourPerSquareCentimeter: return _value/3.6e2; - case MassFluxUnit.GramPerHourPerSquareMeter: return _value/3.6e6; - case MassFluxUnit.GramPerHourPerSquareMillimeter: return _value/3.6e0; - case MassFluxUnit.GramPerSecondPerSquareCentimeter: return _value/1e-1; - case MassFluxUnit.GramPerSecondPerSquareMeter: return _value/1e3; - case MassFluxUnit.GramPerSecondPerSquareMillimeter: return _value/1e-3; - case MassFluxUnit.KilogramPerHourPerSquareCentimeter: return (_value/3.6e2) * 1e3d; - case MassFluxUnit.KilogramPerHourPerSquareMeter: return (_value/3.6e6) * 1e3d; - case MassFluxUnit.KilogramPerHourPerSquareMillimeter: return (_value/3.6e0) * 1e3d; - case MassFluxUnit.KilogramPerSecondPerSquareCentimeter: return (_value/1e-1) * 1e3d; - case MassFluxUnit.KilogramPerSecondPerSquareMeter: return (_value/1e3) * 1e3d; - case MassFluxUnit.KilogramPerSecondPerSquareMillimeter: return (_value/1e-3) * 1e3d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + MassFluxUnit.GramPerHourPerSquareCentimeter => _value/3.6e2, + MassFluxUnit.GramPerHourPerSquareMeter => _value/3.6e6, + MassFluxUnit.GramPerHourPerSquareMillimeter => _value/3.6e0, + MassFluxUnit.GramPerSecondPerSquareCentimeter => _value/1e-1, + MassFluxUnit.GramPerSecondPerSquareMeter => _value/1e3, + MassFluxUnit.GramPerSecondPerSquareMillimeter => _value/1e-3, + MassFluxUnit.KilogramPerHourPerSquareCentimeter => (_value/3.6e2) * 1e3d, + MassFluxUnit.KilogramPerHourPerSquareMeter => (_value/3.6e6) * 1e3d, + MassFluxUnit.KilogramPerHourPerSquareMillimeter => (_value/3.6e0) * 1e3d, + MassFluxUnit.KilogramPerSecondPerSquareCentimeter => (_value/1e-1) * 1e3d, + MassFluxUnit.KilogramPerSecondPerSquareMeter => (_value/1e3) * 1e3d, + MassFluxUnit.KilogramPerSecondPerSquareMillimeter => (_value/1e-3) * 1e3d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(MassFluxUnit unit) @@ -278,23 +277,22 @@ private double GetValueAs(MassFluxUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case MassFluxUnit.GramPerHourPerSquareCentimeter: return baseUnitValue*3.6e2; - case MassFluxUnit.GramPerHourPerSquareMeter: return baseUnitValue*3.6e6; - case MassFluxUnit.GramPerHourPerSquareMillimeter: return baseUnitValue*3.6e0; - case MassFluxUnit.GramPerSecondPerSquareCentimeter: return baseUnitValue*1e-1; - case MassFluxUnit.GramPerSecondPerSquareMeter: return baseUnitValue*1e3; - case MassFluxUnit.GramPerSecondPerSquareMillimeter: return baseUnitValue*1e-3; - case MassFluxUnit.KilogramPerHourPerSquareCentimeter: return (baseUnitValue*3.6e2) / 1e3d; - case MassFluxUnit.KilogramPerHourPerSquareMeter: return (baseUnitValue*3.6e6) / 1e3d; - case MassFluxUnit.KilogramPerHourPerSquareMillimeter: return (baseUnitValue*3.6e0) / 1e3d; - case MassFluxUnit.KilogramPerSecondPerSquareCentimeter: return (baseUnitValue*1e-1) / 1e3d; - case MassFluxUnit.KilogramPerSecondPerSquareMeter: return (baseUnitValue*1e3) / 1e3d; - case MassFluxUnit.KilogramPerSecondPerSquareMillimeter: return (baseUnitValue*1e-3) / 1e3d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + MassFluxUnit.GramPerHourPerSquareCentimeter => baseUnitValue*3.6e2, + MassFluxUnit.GramPerHourPerSquareMeter => baseUnitValue*3.6e6, + MassFluxUnit.GramPerHourPerSquareMillimeter => baseUnitValue*3.6e0, + MassFluxUnit.GramPerSecondPerSquareCentimeter => baseUnitValue*1e-1, + MassFluxUnit.GramPerSecondPerSquareMeter => baseUnitValue*1e3, + MassFluxUnit.GramPerSecondPerSquareMillimeter => baseUnitValue*1e-3, + MassFluxUnit.KilogramPerHourPerSquareCentimeter => (baseUnitValue*3.6e2) / 1e3d, + MassFluxUnit.KilogramPerHourPerSquareMeter => (baseUnitValue*3.6e6) / 1e3d, + MassFluxUnit.KilogramPerHourPerSquareMillimeter => (baseUnitValue*3.6e0) / 1e3d, + MassFluxUnit.KilogramPerSecondPerSquareCentimeter => (baseUnitValue*1e-1) / 1e3d, + MassFluxUnit.KilogramPerSecondPerSquareMeter => (baseUnitValue*1e3) / 1e3d, + MassFluxUnit.KilogramPerSecondPerSquareMillimeter => (baseUnitValue*1e-3) / 1e3d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFraction.g.cs index 0a916df49c..8110a453d3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFraction.g.cs @@ -387,35 +387,34 @@ public MassFraction ToUnit(MassFractionUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case MassFractionUnit.CentigramPerGram: return (_value) * 1e-2d; - case MassFractionUnit.CentigramPerKilogram: return (_value/1e3) * 1e-2d; - case MassFractionUnit.DecagramPerGram: return (_value) * 1e1d; - case MassFractionUnit.DecagramPerKilogram: return (_value/1e3) * 1e1d; - case MassFractionUnit.DecigramPerGram: return (_value) * 1e-1d; - case MassFractionUnit.DecigramPerKilogram: return (_value/1e3) * 1e-1d; - case MassFractionUnit.DecimalFraction: return _value; - case MassFractionUnit.GramPerGram: return _value; - case MassFractionUnit.GramPerKilogram: return _value/1e3; - case MassFractionUnit.HectogramPerGram: return (_value) * 1e2d; - case MassFractionUnit.HectogramPerKilogram: return (_value/1e3) * 1e2d; - case MassFractionUnit.KilogramPerGram: return (_value) * 1e3d; - case MassFractionUnit.KilogramPerKilogram: return (_value/1e3) * 1e3d; - case MassFractionUnit.MicrogramPerGram: return (_value) * 1e-6d; - case MassFractionUnit.MicrogramPerKilogram: return (_value/1e3) * 1e-6d; - case MassFractionUnit.MilligramPerGram: return (_value) * 1e-3d; - case MassFractionUnit.MilligramPerKilogram: return (_value/1e3) * 1e-3d; - case MassFractionUnit.NanogramPerGram: return (_value) * 1e-9d; - case MassFractionUnit.NanogramPerKilogram: return (_value/1e3) * 1e-9d; - case MassFractionUnit.PartPerBillion: return _value/1e9; - case MassFractionUnit.PartPerMillion: return _value/1e6; - case MassFractionUnit.PartPerThousand: return _value/1e3; - case MassFractionUnit.PartPerTrillion: return _value/1e12; - case MassFractionUnit.Percent: return _value/1e2; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + MassFractionUnit.CentigramPerGram => (_value) * 1e-2d, + MassFractionUnit.CentigramPerKilogram => (_value/1e3) * 1e-2d, + MassFractionUnit.DecagramPerGram => (_value) * 1e1d, + MassFractionUnit.DecagramPerKilogram => (_value/1e3) * 1e1d, + MassFractionUnit.DecigramPerGram => (_value) * 1e-1d, + MassFractionUnit.DecigramPerKilogram => (_value/1e3) * 1e-1d, + MassFractionUnit.DecimalFraction => _value, + MassFractionUnit.GramPerGram => _value, + MassFractionUnit.GramPerKilogram => _value/1e3, + MassFractionUnit.HectogramPerGram => (_value) * 1e2d, + MassFractionUnit.HectogramPerKilogram => (_value/1e3) * 1e2d, + MassFractionUnit.KilogramPerGram => (_value) * 1e3d, + MassFractionUnit.KilogramPerKilogram => (_value/1e3) * 1e3d, + MassFractionUnit.MicrogramPerGram => (_value) * 1e-6d, + MassFractionUnit.MicrogramPerKilogram => (_value/1e3) * 1e-6d, + MassFractionUnit.MilligramPerGram => (_value) * 1e-3d, + MassFractionUnit.MilligramPerKilogram => (_value/1e3) * 1e-3d, + MassFractionUnit.NanogramPerGram => (_value) * 1e-9d, + MassFractionUnit.NanogramPerKilogram => (_value/1e3) * 1e-9d, + MassFractionUnit.PartPerBillion => _value/1e9, + MassFractionUnit.PartPerMillion => _value/1e6, + MassFractionUnit.PartPerThousand => _value/1e3, + MassFractionUnit.PartPerTrillion => _value/1e12, + MassFractionUnit.Percent => _value/1e2, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(MassFractionUnit unit) @@ -425,35 +424,34 @@ private double GetValueAs(MassFractionUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case MassFractionUnit.CentigramPerGram: return (baseUnitValue) / 1e-2d; - case MassFractionUnit.CentigramPerKilogram: return (baseUnitValue*1e3) / 1e-2d; - case MassFractionUnit.DecagramPerGram: return (baseUnitValue) / 1e1d; - case MassFractionUnit.DecagramPerKilogram: return (baseUnitValue*1e3) / 1e1d; - case MassFractionUnit.DecigramPerGram: return (baseUnitValue) / 1e-1d; - case MassFractionUnit.DecigramPerKilogram: return (baseUnitValue*1e3) / 1e-1d; - case MassFractionUnit.DecimalFraction: return baseUnitValue; - case MassFractionUnit.GramPerGram: return baseUnitValue; - case MassFractionUnit.GramPerKilogram: return baseUnitValue*1e3; - case MassFractionUnit.HectogramPerGram: return (baseUnitValue) / 1e2d; - case MassFractionUnit.HectogramPerKilogram: return (baseUnitValue*1e3) / 1e2d; - case MassFractionUnit.KilogramPerGram: return (baseUnitValue) / 1e3d; - case MassFractionUnit.KilogramPerKilogram: return (baseUnitValue*1e3) / 1e3d; - case MassFractionUnit.MicrogramPerGram: return (baseUnitValue) / 1e-6d; - case MassFractionUnit.MicrogramPerKilogram: return (baseUnitValue*1e3) / 1e-6d; - case MassFractionUnit.MilligramPerGram: return (baseUnitValue) / 1e-3d; - case MassFractionUnit.MilligramPerKilogram: return (baseUnitValue*1e3) / 1e-3d; - case MassFractionUnit.NanogramPerGram: return (baseUnitValue) / 1e-9d; - case MassFractionUnit.NanogramPerKilogram: return (baseUnitValue*1e3) / 1e-9d; - case MassFractionUnit.PartPerBillion: return baseUnitValue*1e9; - case MassFractionUnit.PartPerMillion: return baseUnitValue*1e6; - case MassFractionUnit.PartPerThousand: return baseUnitValue*1e3; - case MassFractionUnit.PartPerTrillion: return baseUnitValue*1e12; - case MassFractionUnit.Percent: return baseUnitValue*1e2; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + MassFractionUnit.CentigramPerGram => (baseUnitValue) / 1e-2d, + MassFractionUnit.CentigramPerKilogram => (baseUnitValue*1e3) / 1e-2d, + MassFractionUnit.DecagramPerGram => (baseUnitValue) / 1e1d, + MassFractionUnit.DecagramPerKilogram => (baseUnitValue*1e3) / 1e1d, + MassFractionUnit.DecigramPerGram => (baseUnitValue) / 1e-1d, + MassFractionUnit.DecigramPerKilogram => (baseUnitValue*1e3) / 1e-1d, + MassFractionUnit.DecimalFraction => baseUnitValue, + MassFractionUnit.GramPerGram => baseUnitValue, + MassFractionUnit.GramPerKilogram => baseUnitValue*1e3, + MassFractionUnit.HectogramPerGram => (baseUnitValue) / 1e2d, + MassFractionUnit.HectogramPerKilogram => (baseUnitValue*1e3) / 1e2d, + MassFractionUnit.KilogramPerGram => (baseUnitValue) / 1e3d, + MassFractionUnit.KilogramPerKilogram => (baseUnitValue*1e3) / 1e3d, + MassFractionUnit.MicrogramPerGram => (baseUnitValue) / 1e-6d, + MassFractionUnit.MicrogramPerKilogram => (baseUnitValue*1e3) / 1e-6d, + MassFractionUnit.MilligramPerGram => (baseUnitValue) / 1e-3d, + MassFractionUnit.MilligramPerKilogram => (baseUnitValue*1e3) / 1e-3d, + MassFractionUnit.NanogramPerGram => (baseUnitValue) / 1e-9d, + MassFractionUnit.NanogramPerKilogram => (baseUnitValue*1e3) / 1e-9d, + MassFractionUnit.PartPerBillion => baseUnitValue*1e9, + MassFractionUnit.PartPerMillion => baseUnitValue*1e6, + MassFractionUnit.PartPerThousand => baseUnitValue*1e3, + MassFractionUnit.PartPerTrillion => baseUnitValue*1e12, + MassFractionUnit.Percent => baseUnitValue*1e2, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index ea661e4ef8..a149b8c6d0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -428,39 +428,38 @@ public MassMomentOfInertia ToUnit(MassMomentOfInertiaUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case MassMomentOfInertiaUnit.GramSquareCentimeter: return _value/1e7; - case MassMomentOfInertiaUnit.GramSquareDecimeter: return _value/1e5; - case MassMomentOfInertiaUnit.GramSquareMeter: return _value/1e3; - case MassMomentOfInertiaUnit.GramSquareMillimeter: return _value/1e9; - case MassMomentOfInertiaUnit.KilogramSquareCentimeter: return (_value/1e7) * 1e3d; - case MassMomentOfInertiaUnit.KilogramSquareDecimeter: return (_value/1e5) * 1e3d; - case MassMomentOfInertiaUnit.KilogramSquareMeter: return (_value/1e3) * 1e3d; - case MassMomentOfInertiaUnit.KilogramSquareMillimeter: return (_value/1e9) * 1e3d; - case MassMomentOfInertiaUnit.KilotonneSquareCentimeter: return (_value/1e1) * 1e3d; - case MassMomentOfInertiaUnit.KilotonneSquareDecimeter: return (_value/1e-1) * 1e3d; - case MassMomentOfInertiaUnit.KilotonneSquareMeter: return (_value/1e-3) * 1e3d; - case MassMomentOfInertiaUnit.KilotonneSquareMilimeter: return (_value/1e3) * 1e3d; - case MassMomentOfInertiaUnit.MegatonneSquareCentimeter: return (_value/1e1) * 1e6d; - case MassMomentOfInertiaUnit.MegatonneSquareDecimeter: return (_value/1e-1) * 1e6d; - case MassMomentOfInertiaUnit.MegatonneSquareMeter: return (_value/1e-3) * 1e6d; - case MassMomentOfInertiaUnit.MegatonneSquareMilimeter: return (_value/1e3) * 1e6d; - case MassMomentOfInertiaUnit.MilligramSquareCentimeter: return (_value/1e7) * 1e-3d; - case MassMomentOfInertiaUnit.MilligramSquareDecimeter: return (_value/1e5) * 1e-3d; - case MassMomentOfInertiaUnit.MilligramSquareMeter: return (_value/1e3) * 1e-3d; - case MassMomentOfInertiaUnit.MilligramSquareMillimeter: return (_value/1e9) * 1e-3d; - case MassMomentOfInertiaUnit.PoundSquareFoot: return _value*4.21401101e-2; - case MassMomentOfInertiaUnit.PoundSquareInch: return _value*2.9263965e-4; - case MassMomentOfInertiaUnit.SlugSquareFoot: return _value*1.3558179619; - case MassMomentOfInertiaUnit.SlugSquareInch: return _value*9.41540242e-3; - case MassMomentOfInertiaUnit.TonneSquareCentimeter: return _value/1e1; - case MassMomentOfInertiaUnit.TonneSquareDecimeter: return _value/1e-1; - case MassMomentOfInertiaUnit.TonneSquareMeter: return _value/1e-3; - case MassMomentOfInertiaUnit.TonneSquareMilimeter: return _value/1e3; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + MassMomentOfInertiaUnit.GramSquareCentimeter => _value/1e7, + MassMomentOfInertiaUnit.GramSquareDecimeter => _value/1e5, + MassMomentOfInertiaUnit.GramSquareMeter => _value/1e3, + MassMomentOfInertiaUnit.GramSquareMillimeter => _value/1e9, + MassMomentOfInertiaUnit.KilogramSquareCentimeter => (_value/1e7) * 1e3d, + MassMomentOfInertiaUnit.KilogramSquareDecimeter => (_value/1e5) * 1e3d, + MassMomentOfInertiaUnit.KilogramSquareMeter => (_value/1e3) * 1e3d, + MassMomentOfInertiaUnit.KilogramSquareMillimeter => (_value/1e9) * 1e3d, + MassMomentOfInertiaUnit.KilotonneSquareCentimeter => (_value/1e1) * 1e3d, + MassMomentOfInertiaUnit.KilotonneSquareDecimeter => (_value/1e-1) * 1e3d, + MassMomentOfInertiaUnit.KilotonneSquareMeter => (_value/1e-3) * 1e3d, + MassMomentOfInertiaUnit.KilotonneSquareMilimeter => (_value/1e3) * 1e3d, + MassMomentOfInertiaUnit.MegatonneSquareCentimeter => (_value/1e1) * 1e6d, + MassMomentOfInertiaUnit.MegatonneSquareDecimeter => (_value/1e-1) * 1e6d, + MassMomentOfInertiaUnit.MegatonneSquareMeter => (_value/1e-3) * 1e6d, + MassMomentOfInertiaUnit.MegatonneSquareMilimeter => (_value/1e3) * 1e6d, + MassMomentOfInertiaUnit.MilligramSquareCentimeter => (_value/1e7) * 1e-3d, + MassMomentOfInertiaUnit.MilligramSquareDecimeter => (_value/1e5) * 1e-3d, + MassMomentOfInertiaUnit.MilligramSquareMeter => (_value/1e3) * 1e-3d, + MassMomentOfInertiaUnit.MilligramSquareMillimeter => (_value/1e9) * 1e-3d, + MassMomentOfInertiaUnit.PoundSquareFoot => _value*4.21401101e-2, + MassMomentOfInertiaUnit.PoundSquareInch => _value*2.9263965e-4, + MassMomentOfInertiaUnit.SlugSquareFoot => _value*1.3558179619, + MassMomentOfInertiaUnit.SlugSquareInch => _value*9.41540242e-3, + MassMomentOfInertiaUnit.TonneSquareCentimeter => _value/1e1, + MassMomentOfInertiaUnit.TonneSquareDecimeter => _value/1e-1, + MassMomentOfInertiaUnit.TonneSquareMeter => _value/1e-3, + MassMomentOfInertiaUnit.TonneSquareMilimeter => _value/1e3, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(MassMomentOfInertiaUnit unit) @@ -470,39 +469,38 @@ private double GetValueAs(MassMomentOfInertiaUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case MassMomentOfInertiaUnit.GramSquareCentimeter: return baseUnitValue*1e7; - case MassMomentOfInertiaUnit.GramSquareDecimeter: return baseUnitValue*1e5; - case MassMomentOfInertiaUnit.GramSquareMeter: return baseUnitValue*1e3; - case MassMomentOfInertiaUnit.GramSquareMillimeter: return baseUnitValue*1e9; - case MassMomentOfInertiaUnit.KilogramSquareCentimeter: return (baseUnitValue*1e7) / 1e3d; - case MassMomentOfInertiaUnit.KilogramSquareDecimeter: return (baseUnitValue*1e5) / 1e3d; - case MassMomentOfInertiaUnit.KilogramSquareMeter: return (baseUnitValue*1e3) / 1e3d; - case MassMomentOfInertiaUnit.KilogramSquareMillimeter: return (baseUnitValue*1e9) / 1e3d; - case MassMomentOfInertiaUnit.KilotonneSquareCentimeter: return (baseUnitValue*1e1) / 1e3d; - case MassMomentOfInertiaUnit.KilotonneSquareDecimeter: return (baseUnitValue*1e-1) / 1e3d; - case MassMomentOfInertiaUnit.KilotonneSquareMeter: return (baseUnitValue*1e-3) / 1e3d; - case MassMomentOfInertiaUnit.KilotonneSquareMilimeter: return (baseUnitValue*1e3) / 1e3d; - case MassMomentOfInertiaUnit.MegatonneSquareCentimeter: return (baseUnitValue*1e1) / 1e6d; - case MassMomentOfInertiaUnit.MegatonneSquareDecimeter: return (baseUnitValue*1e-1) / 1e6d; - case MassMomentOfInertiaUnit.MegatonneSquareMeter: return (baseUnitValue*1e-3) / 1e6d; - case MassMomentOfInertiaUnit.MegatonneSquareMilimeter: return (baseUnitValue*1e3) / 1e6d; - case MassMomentOfInertiaUnit.MilligramSquareCentimeter: return (baseUnitValue*1e7) / 1e-3d; - case MassMomentOfInertiaUnit.MilligramSquareDecimeter: return (baseUnitValue*1e5) / 1e-3d; - case MassMomentOfInertiaUnit.MilligramSquareMeter: return (baseUnitValue*1e3) / 1e-3d; - case MassMomentOfInertiaUnit.MilligramSquareMillimeter: return (baseUnitValue*1e9) / 1e-3d; - case MassMomentOfInertiaUnit.PoundSquareFoot: return baseUnitValue/4.21401101e-2; - case MassMomentOfInertiaUnit.PoundSquareInch: return baseUnitValue/2.9263965e-4; - case MassMomentOfInertiaUnit.SlugSquareFoot: return baseUnitValue/1.3558179619; - case MassMomentOfInertiaUnit.SlugSquareInch: return baseUnitValue/9.41540242e-3; - case MassMomentOfInertiaUnit.TonneSquareCentimeter: return baseUnitValue*1e1; - case MassMomentOfInertiaUnit.TonneSquareDecimeter: return baseUnitValue*1e-1; - case MassMomentOfInertiaUnit.TonneSquareMeter: return baseUnitValue*1e-3; - case MassMomentOfInertiaUnit.TonneSquareMilimeter: return baseUnitValue*1e3; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + MassMomentOfInertiaUnit.GramSquareCentimeter => baseUnitValue*1e7, + MassMomentOfInertiaUnit.GramSquareDecimeter => baseUnitValue*1e5, + MassMomentOfInertiaUnit.GramSquareMeter => baseUnitValue*1e3, + MassMomentOfInertiaUnit.GramSquareMillimeter => baseUnitValue*1e9, + MassMomentOfInertiaUnit.KilogramSquareCentimeter => (baseUnitValue*1e7) / 1e3d, + MassMomentOfInertiaUnit.KilogramSquareDecimeter => (baseUnitValue*1e5) / 1e3d, + MassMomentOfInertiaUnit.KilogramSquareMeter => (baseUnitValue*1e3) / 1e3d, + MassMomentOfInertiaUnit.KilogramSquareMillimeter => (baseUnitValue*1e9) / 1e3d, + MassMomentOfInertiaUnit.KilotonneSquareCentimeter => (baseUnitValue*1e1) / 1e3d, + MassMomentOfInertiaUnit.KilotonneSquareDecimeter => (baseUnitValue*1e-1) / 1e3d, + MassMomentOfInertiaUnit.KilotonneSquareMeter => (baseUnitValue*1e-3) / 1e3d, + MassMomentOfInertiaUnit.KilotonneSquareMilimeter => (baseUnitValue*1e3) / 1e3d, + MassMomentOfInertiaUnit.MegatonneSquareCentimeter => (baseUnitValue*1e1) / 1e6d, + MassMomentOfInertiaUnit.MegatonneSquareDecimeter => (baseUnitValue*1e-1) / 1e6d, + MassMomentOfInertiaUnit.MegatonneSquareMeter => (baseUnitValue*1e-3) / 1e6d, + MassMomentOfInertiaUnit.MegatonneSquareMilimeter => (baseUnitValue*1e3) / 1e6d, + MassMomentOfInertiaUnit.MilligramSquareCentimeter => (baseUnitValue*1e7) / 1e-3d, + MassMomentOfInertiaUnit.MilligramSquareDecimeter => (baseUnitValue*1e5) / 1e-3d, + MassMomentOfInertiaUnit.MilligramSquareMeter => (baseUnitValue*1e3) / 1e-3d, + MassMomentOfInertiaUnit.MilligramSquareMillimeter => (baseUnitValue*1e9) / 1e-3d, + MassMomentOfInertiaUnit.PoundSquareFoot => baseUnitValue/4.21401101e-2, + MassMomentOfInertiaUnit.PoundSquareInch => baseUnitValue/2.9263965e-4, + MassMomentOfInertiaUnit.SlugSquareFoot => baseUnitValue/1.3558179619, + MassMomentOfInertiaUnit.SlugSquareInch => baseUnitValue/9.41540242e-3, + MassMomentOfInertiaUnit.TonneSquareCentimeter => baseUnitValue*1e1, + MassMomentOfInertiaUnit.TonneSquareDecimeter => baseUnitValue*1e-1, + MassMomentOfInertiaUnit.TonneSquareMeter => baseUnitValue*1e-3, + MassMomentOfInertiaUnit.TonneSquareMilimeter => baseUnitValue*1e3, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEnergy.g.cs index 8a4ed27258..ac63be5532 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -153,14 +153,13 @@ public MolarEnergy ToUnit(MolarEnergyUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case MolarEnergyUnit.JoulePerMole: return _value; - case MolarEnergyUnit.KilojoulePerMole: return (_value) * 1e3d; - case MolarEnergyUnit.MegajoulePerMole: return (_value) * 1e6d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + MolarEnergyUnit.JoulePerMole => _value, + MolarEnergyUnit.KilojoulePerMole => (_value) * 1e3d, + MolarEnergyUnit.MegajoulePerMole => (_value) * 1e6d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(MolarEnergyUnit unit) @@ -170,14 +169,13 @@ private double GetValueAs(MolarEnergyUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case MolarEnergyUnit.JoulePerMole: return baseUnitValue; - case MolarEnergyUnit.KilojoulePerMole: return (baseUnitValue) / 1e3d; - case MolarEnergyUnit.MegajoulePerMole: return (baseUnitValue) / 1e6d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + MolarEnergyUnit.JoulePerMole => baseUnitValue, + MolarEnergyUnit.KilojoulePerMole => (baseUnitValue) / 1e3d, + MolarEnergyUnit.MegajoulePerMole => (baseUnitValue) / 1e6d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEntropy.g.cs index edd6d47b6a..243de7f1b7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -153,14 +153,13 @@ public MolarEntropy ToUnit(MolarEntropyUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case MolarEntropyUnit.JoulePerMoleKelvin: return _value; - case MolarEntropyUnit.KilojoulePerMoleKelvin: return (_value) * 1e3d; - case MolarEntropyUnit.MegajoulePerMoleKelvin: return (_value) * 1e6d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + MolarEntropyUnit.JoulePerMoleKelvin => _value, + MolarEntropyUnit.KilojoulePerMoleKelvin => (_value) * 1e3d, + MolarEntropyUnit.MegajoulePerMoleKelvin => (_value) * 1e6d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(MolarEntropyUnit unit) @@ -170,14 +169,13 @@ private double GetValueAs(MolarEntropyUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case MolarEntropyUnit.JoulePerMoleKelvin: return baseUnitValue; - case MolarEntropyUnit.KilojoulePerMoleKelvin: return (baseUnitValue) / 1e3d; - case MolarEntropyUnit.MegajoulePerMoleKelvin: return (baseUnitValue) / 1e6d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + MolarEntropyUnit.JoulePerMoleKelvin => baseUnitValue, + MolarEntropyUnit.KilojoulePerMoleKelvin => (baseUnitValue) / 1e3d, + MolarEntropyUnit.MegajoulePerMoleKelvin => (baseUnitValue) / 1e6d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarMass.g.cs index 2bbf148135..95b07d7885 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarMass.g.cs @@ -252,23 +252,22 @@ public MolarMass ToUnit(MolarMassUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case MolarMassUnit.CentigramPerMole: return (_value/1e3) * 1e-2d; - case MolarMassUnit.DecagramPerMole: return (_value/1e3) * 1e1d; - case MolarMassUnit.DecigramPerMole: return (_value/1e3) * 1e-1d; - case MolarMassUnit.GramPerMole: return _value/1e3; - case MolarMassUnit.HectogramPerMole: return (_value/1e3) * 1e2d; - case MolarMassUnit.KilogramPerMole: return (_value/1e3) * 1e3d; - case MolarMassUnit.KilopoundPerMole: return (_value*0.45359237) * 1e3d; - case MolarMassUnit.MegapoundPerMole: return (_value*0.45359237) * 1e6d; - case MolarMassUnit.MicrogramPerMole: return (_value/1e3) * 1e-6d; - case MolarMassUnit.MilligramPerMole: return (_value/1e3) * 1e-3d; - case MolarMassUnit.NanogramPerMole: return (_value/1e3) * 1e-9d; - case MolarMassUnit.PoundPerMole: return _value*0.45359237; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + MolarMassUnit.CentigramPerMole => (_value/1e3) * 1e-2d, + MolarMassUnit.DecagramPerMole => (_value/1e3) * 1e1d, + MolarMassUnit.DecigramPerMole => (_value/1e3) * 1e-1d, + MolarMassUnit.GramPerMole => _value/1e3, + MolarMassUnit.HectogramPerMole => (_value/1e3) * 1e2d, + MolarMassUnit.KilogramPerMole => (_value/1e3) * 1e3d, + MolarMassUnit.KilopoundPerMole => (_value*0.45359237) * 1e3d, + MolarMassUnit.MegapoundPerMole => (_value*0.45359237) * 1e6d, + MolarMassUnit.MicrogramPerMole => (_value/1e3) * 1e-6d, + MolarMassUnit.MilligramPerMole => (_value/1e3) * 1e-3d, + MolarMassUnit.NanogramPerMole => (_value/1e3) * 1e-9d, + MolarMassUnit.PoundPerMole => _value*0.45359237, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(MolarMassUnit unit) @@ -278,23 +277,22 @@ private double GetValueAs(MolarMassUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case MolarMassUnit.CentigramPerMole: return (baseUnitValue*1e3) / 1e-2d; - case MolarMassUnit.DecagramPerMole: return (baseUnitValue*1e3) / 1e1d; - case MolarMassUnit.DecigramPerMole: return (baseUnitValue*1e3) / 1e-1d; - case MolarMassUnit.GramPerMole: return baseUnitValue*1e3; - case MolarMassUnit.HectogramPerMole: return (baseUnitValue*1e3) / 1e2d; - case MolarMassUnit.KilogramPerMole: return (baseUnitValue*1e3) / 1e3d; - case MolarMassUnit.KilopoundPerMole: return (baseUnitValue/0.45359237) / 1e3d; - case MolarMassUnit.MegapoundPerMole: return (baseUnitValue/0.45359237) / 1e6d; - case MolarMassUnit.MicrogramPerMole: return (baseUnitValue*1e3) / 1e-6d; - case MolarMassUnit.MilligramPerMole: return (baseUnitValue*1e3) / 1e-3d; - case MolarMassUnit.NanogramPerMole: return (baseUnitValue*1e3) / 1e-9d; - case MolarMassUnit.PoundPerMole: return baseUnitValue/0.45359237; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + MolarMassUnit.CentigramPerMole => (baseUnitValue*1e3) / 1e-2d, + MolarMassUnit.DecagramPerMole => (baseUnitValue*1e3) / 1e1d, + MolarMassUnit.DecigramPerMole => (baseUnitValue*1e3) / 1e-1d, + MolarMassUnit.GramPerMole => baseUnitValue*1e3, + MolarMassUnit.HectogramPerMole => (baseUnitValue*1e3) / 1e2d, + MolarMassUnit.KilogramPerMole => (baseUnitValue*1e3) / 1e3d, + MolarMassUnit.KilopoundPerMole => (baseUnitValue/0.45359237) / 1e3d, + MolarMassUnit.MegapoundPerMole => (baseUnitValue/0.45359237) / 1e6d, + MolarMassUnit.MicrogramPerMole => (baseUnitValue*1e3) / 1e-6d, + MolarMassUnit.MilligramPerMole => (baseUnitValue*1e3) / 1e-3d, + MolarMassUnit.NanogramPerMole => (baseUnitValue*1e3) / 1e-9d, + MolarMassUnit.PoundPerMole => baseUnitValue/0.45359237, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs index 4aff80fa5a..a900b7a0bc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs @@ -211,27 +211,26 @@ public Molarity ToUnit(MolarityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case MolarityUnit.CentimolePerLiter: return (_value / 1e-3) * 1e-2d; - case MolarityUnit.CentimolesPerLiter: return (_value / 1e-3) * 1e-2d; - case MolarityUnit.DecimolePerLiter: return (_value / 1e-3) * 1e-1d; - case MolarityUnit.DecimolesPerLiter: return (_value / 1e-3) * 1e-1d; - case MolarityUnit.MicromolePerLiter: return (_value / 1e-3) * 1e-6d; - case MolarityUnit.MicromolesPerLiter: return (_value / 1e-3) * 1e-6d; - case MolarityUnit.MillimolePerLiter: return (_value / 1e-3) * 1e-3d; - case MolarityUnit.MillimolesPerLiter: return (_value / 1e-3) * 1e-3d; - case MolarityUnit.MolePerCubicMeter: return _value; - case MolarityUnit.MolePerLiter: return _value / 1e-3; - case MolarityUnit.MolesPerCubicMeter: return _value; - case MolarityUnit.MolesPerLiter: return _value / 1e-3; - case MolarityUnit.NanomolePerLiter: return (_value / 1e-3) * 1e-9d; - case MolarityUnit.NanomolesPerLiter: return (_value / 1e-3) * 1e-9d; - case MolarityUnit.PicomolePerLiter: return (_value / 1e-3) * 1e-12d; - case MolarityUnit.PicomolesPerLiter: return (_value / 1e-3) * 1e-12d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + MolarityUnit.CentimolePerLiter => (_value / 1e-3) * 1e-2d, + MolarityUnit.CentimolesPerLiter => (_value / 1e-3) * 1e-2d, + MolarityUnit.DecimolePerLiter => (_value / 1e-3) * 1e-1d, + MolarityUnit.DecimolesPerLiter => (_value / 1e-3) * 1e-1d, + MolarityUnit.MicromolePerLiter => (_value / 1e-3) * 1e-6d, + MolarityUnit.MicromolesPerLiter => (_value / 1e-3) * 1e-6d, + MolarityUnit.MillimolePerLiter => (_value / 1e-3) * 1e-3d, + MolarityUnit.MillimolesPerLiter => (_value / 1e-3) * 1e-3d, + MolarityUnit.MolePerCubicMeter => _value, + MolarityUnit.MolePerLiter => _value / 1e-3, + MolarityUnit.MolesPerCubicMeter => _value, + MolarityUnit.MolesPerLiter => _value / 1e-3, + MolarityUnit.NanomolePerLiter => (_value / 1e-3) * 1e-9d, + MolarityUnit.NanomolesPerLiter => (_value / 1e-3) * 1e-9d, + MolarityUnit.PicomolePerLiter => (_value / 1e-3) * 1e-12d, + MolarityUnit.PicomolesPerLiter => (_value / 1e-3) * 1e-12d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(MolarityUnit unit) @@ -241,27 +240,26 @@ private double GetValueAs(MolarityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case MolarityUnit.CentimolePerLiter: return (baseUnitValue * 1e-3) / 1e-2d; - case MolarityUnit.CentimolesPerLiter: return (baseUnitValue * 1e-3) / 1e-2d; - case MolarityUnit.DecimolePerLiter: return (baseUnitValue * 1e-3) / 1e-1d; - case MolarityUnit.DecimolesPerLiter: return (baseUnitValue * 1e-3) / 1e-1d; - case MolarityUnit.MicromolePerLiter: return (baseUnitValue * 1e-3) / 1e-6d; - case MolarityUnit.MicromolesPerLiter: return (baseUnitValue * 1e-3) / 1e-6d; - case MolarityUnit.MillimolePerLiter: return (baseUnitValue * 1e-3) / 1e-3d; - case MolarityUnit.MillimolesPerLiter: return (baseUnitValue * 1e-3) / 1e-3d; - case MolarityUnit.MolePerCubicMeter: return baseUnitValue; - case MolarityUnit.MolePerLiter: return baseUnitValue * 1e-3; - case MolarityUnit.MolesPerCubicMeter: return baseUnitValue; - case MolarityUnit.MolesPerLiter: return baseUnitValue * 1e-3; - case MolarityUnit.NanomolePerLiter: return (baseUnitValue * 1e-3) / 1e-9d; - case MolarityUnit.NanomolesPerLiter: return (baseUnitValue * 1e-3) / 1e-9d; - case MolarityUnit.PicomolePerLiter: return (baseUnitValue * 1e-3) / 1e-12d; - case MolarityUnit.PicomolesPerLiter: return (baseUnitValue * 1e-3) / 1e-12d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + MolarityUnit.CentimolePerLiter => (baseUnitValue * 1e-3) / 1e-2d, + MolarityUnit.CentimolesPerLiter => (baseUnitValue * 1e-3) / 1e-2d, + MolarityUnit.DecimolePerLiter => (baseUnitValue * 1e-3) / 1e-1d, + MolarityUnit.DecimolesPerLiter => (baseUnitValue * 1e-3) / 1e-1d, + MolarityUnit.MicromolePerLiter => (baseUnitValue * 1e-3) / 1e-6d, + MolarityUnit.MicromolesPerLiter => (baseUnitValue * 1e-3) / 1e-6d, + MolarityUnit.MillimolePerLiter => (baseUnitValue * 1e-3) / 1e-3d, + MolarityUnit.MillimolesPerLiter => (baseUnitValue * 1e-3) / 1e-3d, + MolarityUnit.MolePerCubicMeter => baseUnitValue, + MolarityUnit.MolePerLiter => baseUnitValue * 1e-3, + MolarityUnit.MolesPerCubicMeter => baseUnitValue, + MolarityUnit.MolesPerLiter => baseUnitValue * 1e-3, + MolarityUnit.NanomolePerLiter => (baseUnitValue * 1e-3) / 1e-9d, + MolarityUnit.NanomolesPerLiter => (baseUnitValue * 1e-3) / 1e-9d, + MolarityUnit.PicomolePerLiter => (baseUnitValue * 1e-3) / 1e-12d, + MolarityUnit.PicomolesPerLiter => (baseUnitValue * 1e-3) / 1e-12d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permeability.g.cs index eb0589d721..c750d7bdc5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permeability.g.cs @@ -134,12 +134,11 @@ public Permeability ToUnit(PermeabilityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case PermeabilityUnit.HenryPerMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + PermeabilityUnit.HenryPerMeter => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(PermeabilityUnit unit) @@ -149,12 +148,11 @@ private double GetValueAs(PermeabilityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case PermeabilityUnit.HenryPerMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + PermeabilityUnit.HenryPerMeter => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permittivity.g.cs index 83082319c8..d1c6c3ac2c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permittivity.g.cs @@ -134,12 +134,11 @@ public Permittivity ToUnit(PermittivityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case PermittivityUnit.FaradPerMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + PermittivityUnit.FaradPerMeter => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(PermittivityUnit unit) @@ -149,12 +148,11 @@ private double GetValueAs(PermittivityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case PermittivityUnit.FaradPerMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + PermittivityUnit.FaradPerMeter => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs index 35e3056626..065871d705 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs @@ -395,36 +395,35 @@ public Power ToUnit(PowerUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case PowerUnit.BoilerHorsepower: return _value*9812.5d; - case PowerUnit.BritishThermalUnitPerHour: return _value*0.293071d; - case PowerUnit.Decawatt: return (_value) * 1e1d; - case PowerUnit.Deciwatt: return (_value) * 1e-1d; - case PowerUnit.ElectricalHorsepower: return _value*746d; - case PowerUnit.Femtowatt: return (_value) * 1e-15d; - case PowerUnit.GigajoulePerHour: return (_value/3600d) * 1e9d; - case PowerUnit.Gigawatt: return (_value) * 1e9d; - case PowerUnit.HydraulicHorsepower: return _value*745.69988145d; - case PowerUnit.JoulePerHour: return _value/3600d; - case PowerUnit.KilobritishThermalUnitPerHour: return (_value*0.293071d) * 1e3d; - case PowerUnit.KilojoulePerHour: return (_value/3600d) * 1e3d; - case PowerUnit.Kilowatt: return (_value) * 1e3d; - case PowerUnit.MechanicalHorsepower: return _value*745.69d; - case PowerUnit.MegajoulePerHour: return (_value/3600d) * 1e6d; - case PowerUnit.Megawatt: return (_value) * 1e6d; - case PowerUnit.MetricHorsepower: return _value*735.49875d; - case PowerUnit.Microwatt: return (_value) * 1e-6d; - case PowerUnit.MillijoulePerHour: return (_value/3600d) * 1e-3d; - case PowerUnit.Milliwatt: return (_value) * 1e-3d; - case PowerUnit.Nanowatt: return (_value) * 1e-9d; - case PowerUnit.Petawatt: return (_value) * 1e15d; - case PowerUnit.Picowatt: return (_value) * 1e-12d; - case PowerUnit.Terawatt: return (_value) * 1e12d; - case PowerUnit.Watt: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + PowerUnit.BoilerHorsepower => _value*9812.5d, + PowerUnit.BritishThermalUnitPerHour => _value*0.293071d, + PowerUnit.Decawatt => (_value) * 1e1d, + PowerUnit.Deciwatt => (_value) * 1e-1d, + PowerUnit.ElectricalHorsepower => _value*746d, + PowerUnit.Femtowatt => (_value) * 1e-15d, + PowerUnit.GigajoulePerHour => (_value/3600d) * 1e9d, + PowerUnit.Gigawatt => (_value) * 1e9d, + PowerUnit.HydraulicHorsepower => _value*745.69988145d, + PowerUnit.JoulePerHour => _value/3600d, + PowerUnit.KilobritishThermalUnitPerHour => (_value*0.293071d) * 1e3d, + PowerUnit.KilojoulePerHour => (_value/3600d) * 1e3d, + PowerUnit.Kilowatt => (_value) * 1e3d, + PowerUnit.MechanicalHorsepower => _value*745.69d, + PowerUnit.MegajoulePerHour => (_value/3600d) * 1e6d, + PowerUnit.Megawatt => (_value) * 1e6d, + PowerUnit.MetricHorsepower => _value*735.49875d, + PowerUnit.Microwatt => (_value) * 1e-6d, + PowerUnit.MillijoulePerHour => (_value/3600d) * 1e-3d, + PowerUnit.Milliwatt => (_value) * 1e-3d, + PowerUnit.Nanowatt => (_value) * 1e-9d, + PowerUnit.Petawatt => (_value) * 1e15d, + PowerUnit.Picowatt => (_value) * 1e-12d, + PowerUnit.Terawatt => (_value) * 1e12d, + PowerUnit.Watt => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(PowerUnit unit) @@ -434,36 +433,35 @@ private double GetValueAs(PowerUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case PowerUnit.BoilerHorsepower: return baseUnitValue/9812.5d; - case PowerUnit.BritishThermalUnitPerHour: return baseUnitValue/0.293071d; - case PowerUnit.Decawatt: return (baseUnitValue) / 1e1d; - case PowerUnit.Deciwatt: return (baseUnitValue) / 1e-1d; - case PowerUnit.ElectricalHorsepower: return baseUnitValue/746d; - case PowerUnit.Femtowatt: return (baseUnitValue) / 1e-15d; - case PowerUnit.GigajoulePerHour: return (baseUnitValue*3600d) / 1e9d; - case PowerUnit.Gigawatt: return (baseUnitValue) / 1e9d; - case PowerUnit.HydraulicHorsepower: return baseUnitValue/745.69988145d; - case PowerUnit.JoulePerHour: return baseUnitValue*3600d; - case PowerUnit.KilobritishThermalUnitPerHour: return (baseUnitValue/0.293071d) / 1e3d; - case PowerUnit.KilojoulePerHour: return (baseUnitValue*3600d) / 1e3d; - case PowerUnit.Kilowatt: return (baseUnitValue) / 1e3d; - case PowerUnit.MechanicalHorsepower: return baseUnitValue/745.69d; - case PowerUnit.MegajoulePerHour: return (baseUnitValue*3600d) / 1e6d; - case PowerUnit.Megawatt: return (baseUnitValue) / 1e6d; - case PowerUnit.MetricHorsepower: return baseUnitValue/735.49875d; - case PowerUnit.Microwatt: return (baseUnitValue) / 1e-6d; - case PowerUnit.MillijoulePerHour: return (baseUnitValue*3600d) / 1e-3d; - case PowerUnit.Milliwatt: return (baseUnitValue) / 1e-3d; - case PowerUnit.Nanowatt: return (baseUnitValue) / 1e-9d; - case PowerUnit.Petawatt: return (baseUnitValue) / 1e15d; - case PowerUnit.Picowatt: return (baseUnitValue) / 1e-12d; - case PowerUnit.Terawatt: return (baseUnitValue) / 1e12d; - case PowerUnit.Watt: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + PowerUnit.BoilerHorsepower => baseUnitValue/9812.5d, + PowerUnit.BritishThermalUnitPerHour => baseUnitValue/0.293071d, + PowerUnit.Decawatt => (baseUnitValue) / 1e1d, + PowerUnit.Deciwatt => (baseUnitValue) / 1e-1d, + PowerUnit.ElectricalHorsepower => baseUnitValue/746d, + PowerUnit.Femtowatt => (baseUnitValue) / 1e-15d, + PowerUnit.GigajoulePerHour => (baseUnitValue*3600d) / 1e9d, + PowerUnit.Gigawatt => (baseUnitValue) / 1e9d, + PowerUnit.HydraulicHorsepower => baseUnitValue/745.69988145d, + PowerUnit.JoulePerHour => baseUnitValue*3600d, + PowerUnit.KilobritishThermalUnitPerHour => (baseUnitValue/0.293071d) / 1e3d, + PowerUnit.KilojoulePerHour => (baseUnitValue*3600d) / 1e3d, + PowerUnit.Kilowatt => (baseUnitValue) / 1e3d, + PowerUnit.MechanicalHorsepower => baseUnitValue/745.69d, + PowerUnit.MegajoulePerHour => (baseUnitValue*3600d) / 1e6d, + PowerUnit.Megawatt => (baseUnitValue) / 1e6d, + PowerUnit.MetricHorsepower => baseUnitValue/735.49875d, + PowerUnit.Microwatt => (baseUnitValue) / 1e-6d, + PowerUnit.MillijoulePerHour => (baseUnitValue*3600d) / 1e-3d, + PowerUnit.Milliwatt => (baseUnitValue) / 1e-3d, + PowerUnit.Nanowatt => (baseUnitValue) / 1e-9d, + PowerUnit.Petawatt => (baseUnitValue) / 1e15d, + PowerUnit.Picowatt => (baseUnitValue) / 1e-12d, + PowerUnit.Terawatt => (baseUnitValue) / 1e12d, + PowerUnit.Watt => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerDensity.g.cs index e9134ea091..0fd7c4bb87 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerDensity.g.cs @@ -604,55 +604,54 @@ public PowerDensity ToUnit(PowerDensityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case PowerDensityUnit.DecawattPerCubicFoot: return (_value*3.531466672148859e1) * 1e1d; - case PowerDensityUnit.DecawattPerCubicInch: return (_value*6.102374409473228e4) * 1e1d; - case PowerDensityUnit.DecawattPerCubicMeter: return (_value) * 1e1d; - case PowerDensityUnit.DecawattPerLiter: return (_value*1.0e3) * 1e1d; - case PowerDensityUnit.DeciwattPerCubicFoot: return (_value*3.531466672148859e1) * 1e-1d; - case PowerDensityUnit.DeciwattPerCubicInch: return (_value*6.102374409473228e4) * 1e-1d; - case PowerDensityUnit.DeciwattPerCubicMeter: return (_value) * 1e-1d; - case PowerDensityUnit.DeciwattPerLiter: return (_value*1.0e3) * 1e-1d; - case PowerDensityUnit.GigawattPerCubicFoot: return (_value*3.531466672148859e1) * 1e9d; - case PowerDensityUnit.GigawattPerCubicInch: return (_value*6.102374409473228e4) * 1e9d; - case PowerDensityUnit.GigawattPerCubicMeter: return (_value) * 1e9d; - case PowerDensityUnit.GigawattPerLiter: return (_value*1.0e3) * 1e9d; - case PowerDensityUnit.KilowattPerCubicFoot: return (_value*3.531466672148859e1) * 1e3d; - case PowerDensityUnit.KilowattPerCubicInch: return (_value*6.102374409473228e4) * 1e3d; - case PowerDensityUnit.KilowattPerCubicMeter: return (_value) * 1e3d; - case PowerDensityUnit.KilowattPerLiter: return (_value*1.0e3) * 1e3d; - case PowerDensityUnit.MegawattPerCubicFoot: return (_value*3.531466672148859e1) * 1e6d; - case PowerDensityUnit.MegawattPerCubicInch: return (_value*6.102374409473228e4) * 1e6d; - case PowerDensityUnit.MegawattPerCubicMeter: return (_value) * 1e6d; - case PowerDensityUnit.MegawattPerLiter: return (_value*1.0e3) * 1e6d; - case PowerDensityUnit.MicrowattPerCubicFoot: return (_value*3.531466672148859e1) * 1e-6d; - case PowerDensityUnit.MicrowattPerCubicInch: return (_value*6.102374409473228e4) * 1e-6d; - case PowerDensityUnit.MicrowattPerCubicMeter: return (_value) * 1e-6d; - case PowerDensityUnit.MicrowattPerLiter: return (_value*1.0e3) * 1e-6d; - case PowerDensityUnit.MilliwattPerCubicFoot: return (_value*3.531466672148859e1) * 1e-3d; - case PowerDensityUnit.MilliwattPerCubicInch: return (_value*6.102374409473228e4) * 1e-3d; - case PowerDensityUnit.MilliwattPerCubicMeter: return (_value) * 1e-3d; - case PowerDensityUnit.MilliwattPerLiter: return (_value*1.0e3) * 1e-3d; - case PowerDensityUnit.NanowattPerCubicFoot: return (_value*3.531466672148859e1) * 1e-9d; - case PowerDensityUnit.NanowattPerCubicInch: return (_value*6.102374409473228e4) * 1e-9d; - case PowerDensityUnit.NanowattPerCubicMeter: return (_value) * 1e-9d; - case PowerDensityUnit.NanowattPerLiter: return (_value*1.0e3) * 1e-9d; - case PowerDensityUnit.PicowattPerCubicFoot: return (_value*3.531466672148859e1) * 1e-12d; - case PowerDensityUnit.PicowattPerCubicInch: return (_value*6.102374409473228e4) * 1e-12d; - case PowerDensityUnit.PicowattPerCubicMeter: return (_value) * 1e-12d; - case PowerDensityUnit.PicowattPerLiter: return (_value*1.0e3) * 1e-12d; - case PowerDensityUnit.TerawattPerCubicFoot: return (_value*3.531466672148859e1) * 1e12d; - case PowerDensityUnit.TerawattPerCubicInch: return (_value*6.102374409473228e4) * 1e12d; - case PowerDensityUnit.TerawattPerCubicMeter: return (_value) * 1e12d; - case PowerDensityUnit.TerawattPerLiter: return (_value*1.0e3) * 1e12d; - case PowerDensityUnit.WattPerCubicFoot: return _value*3.531466672148859e1; - case PowerDensityUnit.WattPerCubicInch: return _value*6.102374409473228e4; - case PowerDensityUnit.WattPerCubicMeter: return _value; - case PowerDensityUnit.WattPerLiter: return _value*1.0e3; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + PowerDensityUnit.DecawattPerCubicFoot => (_value*3.531466672148859e1) * 1e1d, + PowerDensityUnit.DecawattPerCubicInch => (_value*6.102374409473228e4) * 1e1d, + PowerDensityUnit.DecawattPerCubicMeter => (_value) * 1e1d, + PowerDensityUnit.DecawattPerLiter => (_value*1.0e3) * 1e1d, + PowerDensityUnit.DeciwattPerCubicFoot => (_value*3.531466672148859e1) * 1e-1d, + PowerDensityUnit.DeciwattPerCubicInch => (_value*6.102374409473228e4) * 1e-1d, + PowerDensityUnit.DeciwattPerCubicMeter => (_value) * 1e-1d, + PowerDensityUnit.DeciwattPerLiter => (_value*1.0e3) * 1e-1d, + PowerDensityUnit.GigawattPerCubicFoot => (_value*3.531466672148859e1) * 1e9d, + PowerDensityUnit.GigawattPerCubicInch => (_value*6.102374409473228e4) * 1e9d, + PowerDensityUnit.GigawattPerCubicMeter => (_value) * 1e9d, + PowerDensityUnit.GigawattPerLiter => (_value*1.0e3) * 1e9d, + PowerDensityUnit.KilowattPerCubicFoot => (_value*3.531466672148859e1) * 1e3d, + PowerDensityUnit.KilowattPerCubicInch => (_value*6.102374409473228e4) * 1e3d, + PowerDensityUnit.KilowattPerCubicMeter => (_value) * 1e3d, + PowerDensityUnit.KilowattPerLiter => (_value*1.0e3) * 1e3d, + PowerDensityUnit.MegawattPerCubicFoot => (_value*3.531466672148859e1) * 1e6d, + PowerDensityUnit.MegawattPerCubicInch => (_value*6.102374409473228e4) * 1e6d, + PowerDensityUnit.MegawattPerCubicMeter => (_value) * 1e6d, + PowerDensityUnit.MegawattPerLiter => (_value*1.0e3) * 1e6d, + PowerDensityUnit.MicrowattPerCubicFoot => (_value*3.531466672148859e1) * 1e-6d, + PowerDensityUnit.MicrowattPerCubicInch => (_value*6.102374409473228e4) * 1e-6d, + PowerDensityUnit.MicrowattPerCubicMeter => (_value) * 1e-6d, + PowerDensityUnit.MicrowattPerLiter => (_value*1.0e3) * 1e-6d, + PowerDensityUnit.MilliwattPerCubicFoot => (_value*3.531466672148859e1) * 1e-3d, + PowerDensityUnit.MilliwattPerCubicInch => (_value*6.102374409473228e4) * 1e-3d, + PowerDensityUnit.MilliwattPerCubicMeter => (_value) * 1e-3d, + PowerDensityUnit.MilliwattPerLiter => (_value*1.0e3) * 1e-3d, + PowerDensityUnit.NanowattPerCubicFoot => (_value*3.531466672148859e1) * 1e-9d, + PowerDensityUnit.NanowattPerCubicInch => (_value*6.102374409473228e4) * 1e-9d, + PowerDensityUnit.NanowattPerCubicMeter => (_value) * 1e-9d, + PowerDensityUnit.NanowattPerLiter => (_value*1.0e3) * 1e-9d, + PowerDensityUnit.PicowattPerCubicFoot => (_value*3.531466672148859e1) * 1e-12d, + PowerDensityUnit.PicowattPerCubicInch => (_value*6.102374409473228e4) * 1e-12d, + PowerDensityUnit.PicowattPerCubicMeter => (_value) * 1e-12d, + PowerDensityUnit.PicowattPerLiter => (_value*1.0e3) * 1e-12d, + PowerDensityUnit.TerawattPerCubicFoot => (_value*3.531466672148859e1) * 1e12d, + PowerDensityUnit.TerawattPerCubicInch => (_value*6.102374409473228e4) * 1e12d, + PowerDensityUnit.TerawattPerCubicMeter => (_value) * 1e12d, + PowerDensityUnit.TerawattPerLiter => (_value*1.0e3) * 1e12d, + PowerDensityUnit.WattPerCubicFoot => _value*3.531466672148859e1, + PowerDensityUnit.WattPerCubicInch => _value*6.102374409473228e4, + PowerDensityUnit.WattPerCubicMeter => _value, + PowerDensityUnit.WattPerLiter => _value*1.0e3, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(PowerDensityUnit unit) @@ -662,55 +661,54 @@ private double GetValueAs(PowerDensityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case PowerDensityUnit.DecawattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e1d; - case PowerDensityUnit.DecawattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e1d; - case PowerDensityUnit.DecawattPerCubicMeter: return (baseUnitValue) / 1e1d; - case PowerDensityUnit.DecawattPerLiter: return (baseUnitValue/1.0e3) / 1e1d; - case PowerDensityUnit.DeciwattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e-1d; - case PowerDensityUnit.DeciwattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e-1d; - case PowerDensityUnit.DeciwattPerCubicMeter: return (baseUnitValue) / 1e-1d; - case PowerDensityUnit.DeciwattPerLiter: return (baseUnitValue/1.0e3) / 1e-1d; - case PowerDensityUnit.GigawattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e9d; - case PowerDensityUnit.GigawattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e9d; - case PowerDensityUnit.GigawattPerCubicMeter: return (baseUnitValue) / 1e9d; - case PowerDensityUnit.GigawattPerLiter: return (baseUnitValue/1.0e3) / 1e9d; - case PowerDensityUnit.KilowattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e3d; - case PowerDensityUnit.KilowattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e3d; - case PowerDensityUnit.KilowattPerCubicMeter: return (baseUnitValue) / 1e3d; - case PowerDensityUnit.KilowattPerLiter: return (baseUnitValue/1.0e3) / 1e3d; - case PowerDensityUnit.MegawattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e6d; - case PowerDensityUnit.MegawattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e6d; - case PowerDensityUnit.MegawattPerCubicMeter: return (baseUnitValue) / 1e6d; - case PowerDensityUnit.MegawattPerLiter: return (baseUnitValue/1.0e3) / 1e6d; - case PowerDensityUnit.MicrowattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e-6d; - case PowerDensityUnit.MicrowattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e-6d; - case PowerDensityUnit.MicrowattPerCubicMeter: return (baseUnitValue) / 1e-6d; - case PowerDensityUnit.MicrowattPerLiter: return (baseUnitValue/1.0e3) / 1e-6d; - case PowerDensityUnit.MilliwattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e-3d; - case PowerDensityUnit.MilliwattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e-3d; - case PowerDensityUnit.MilliwattPerCubicMeter: return (baseUnitValue) / 1e-3d; - case PowerDensityUnit.MilliwattPerLiter: return (baseUnitValue/1.0e3) / 1e-3d; - case PowerDensityUnit.NanowattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e-9d; - case PowerDensityUnit.NanowattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e-9d; - case PowerDensityUnit.NanowattPerCubicMeter: return (baseUnitValue) / 1e-9d; - case PowerDensityUnit.NanowattPerLiter: return (baseUnitValue/1.0e3) / 1e-9d; - case PowerDensityUnit.PicowattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e-12d; - case PowerDensityUnit.PicowattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e-12d; - case PowerDensityUnit.PicowattPerCubicMeter: return (baseUnitValue) / 1e-12d; - case PowerDensityUnit.PicowattPerLiter: return (baseUnitValue/1.0e3) / 1e-12d; - case PowerDensityUnit.TerawattPerCubicFoot: return (baseUnitValue/3.531466672148859e1) / 1e12d; - case PowerDensityUnit.TerawattPerCubicInch: return (baseUnitValue/6.102374409473228e4) / 1e12d; - case PowerDensityUnit.TerawattPerCubicMeter: return (baseUnitValue) / 1e12d; - case PowerDensityUnit.TerawattPerLiter: return (baseUnitValue/1.0e3) / 1e12d; - case PowerDensityUnit.WattPerCubicFoot: return baseUnitValue/3.531466672148859e1; - case PowerDensityUnit.WattPerCubicInch: return baseUnitValue/6.102374409473228e4; - case PowerDensityUnit.WattPerCubicMeter: return baseUnitValue; - case PowerDensityUnit.WattPerLiter: return baseUnitValue/1.0e3; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + PowerDensityUnit.DecawattPerCubicFoot => (baseUnitValue/3.531466672148859e1) / 1e1d, + PowerDensityUnit.DecawattPerCubicInch => (baseUnitValue/6.102374409473228e4) / 1e1d, + PowerDensityUnit.DecawattPerCubicMeter => (baseUnitValue) / 1e1d, + PowerDensityUnit.DecawattPerLiter => (baseUnitValue/1.0e3) / 1e1d, + PowerDensityUnit.DeciwattPerCubicFoot => (baseUnitValue/3.531466672148859e1) / 1e-1d, + PowerDensityUnit.DeciwattPerCubicInch => (baseUnitValue/6.102374409473228e4) / 1e-1d, + PowerDensityUnit.DeciwattPerCubicMeter => (baseUnitValue) / 1e-1d, + PowerDensityUnit.DeciwattPerLiter => (baseUnitValue/1.0e3) / 1e-1d, + PowerDensityUnit.GigawattPerCubicFoot => (baseUnitValue/3.531466672148859e1) / 1e9d, + PowerDensityUnit.GigawattPerCubicInch => (baseUnitValue/6.102374409473228e4) / 1e9d, + PowerDensityUnit.GigawattPerCubicMeter => (baseUnitValue) / 1e9d, + PowerDensityUnit.GigawattPerLiter => (baseUnitValue/1.0e3) / 1e9d, + PowerDensityUnit.KilowattPerCubicFoot => (baseUnitValue/3.531466672148859e1) / 1e3d, + PowerDensityUnit.KilowattPerCubicInch => (baseUnitValue/6.102374409473228e4) / 1e3d, + PowerDensityUnit.KilowattPerCubicMeter => (baseUnitValue) / 1e3d, + PowerDensityUnit.KilowattPerLiter => (baseUnitValue/1.0e3) / 1e3d, + PowerDensityUnit.MegawattPerCubicFoot => (baseUnitValue/3.531466672148859e1) / 1e6d, + PowerDensityUnit.MegawattPerCubicInch => (baseUnitValue/6.102374409473228e4) / 1e6d, + PowerDensityUnit.MegawattPerCubicMeter => (baseUnitValue) / 1e6d, + PowerDensityUnit.MegawattPerLiter => (baseUnitValue/1.0e3) / 1e6d, + PowerDensityUnit.MicrowattPerCubicFoot => (baseUnitValue/3.531466672148859e1) / 1e-6d, + PowerDensityUnit.MicrowattPerCubicInch => (baseUnitValue/6.102374409473228e4) / 1e-6d, + PowerDensityUnit.MicrowattPerCubicMeter => (baseUnitValue) / 1e-6d, + PowerDensityUnit.MicrowattPerLiter => (baseUnitValue/1.0e3) / 1e-6d, + PowerDensityUnit.MilliwattPerCubicFoot => (baseUnitValue/3.531466672148859e1) / 1e-3d, + PowerDensityUnit.MilliwattPerCubicInch => (baseUnitValue/6.102374409473228e4) / 1e-3d, + PowerDensityUnit.MilliwattPerCubicMeter => (baseUnitValue) / 1e-3d, + PowerDensityUnit.MilliwattPerLiter => (baseUnitValue/1.0e3) / 1e-3d, + PowerDensityUnit.NanowattPerCubicFoot => (baseUnitValue/3.531466672148859e1) / 1e-9d, + PowerDensityUnit.NanowattPerCubicInch => (baseUnitValue/6.102374409473228e4) / 1e-9d, + PowerDensityUnit.NanowattPerCubicMeter => (baseUnitValue) / 1e-9d, + PowerDensityUnit.NanowattPerLiter => (baseUnitValue/1.0e3) / 1e-9d, + PowerDensityUnit.PicowattPerCubicFoot => (baseUnitValue/3.531466672148859e1) / 1e-12d, + PowerDensityUnit.PicowattPerCubicInch => (baseUnitValue/6.102374409473228e4) / 1e-12d, + PowerDensityUnit.PicowattPerCubicMeter => (baseUnitValue) / 1e-12d, + PowerDensityUnit.PicowattPerLiter => (baseUnitValue/1.0e3) / 1e-12d, + PowerDensityUnit.TerawattPerCubicFoot => (baseUnitValue/3.531466672148859e1) / 1e12d, + PowerDensityUnit.TerawattPerCubicInch => (baseUnitValue/6.102374409473228e4) / 1e12d, + PowerDensityUnit.TerawattPerCubicMeter => (baseUnitValue) / 1e12d, + PowerDensityUnit.TerawattPerLiter => (baseUnitValue/1.0e3) / 1e12d, + PowerDensityUnit.WattPerCubicFoot => baseUnitValue/3.531466672148859e1, + PowerDensityUnit.WattPerCubicInch => baseUnitValue/6.102374409473228e4, + PowerDensityUnit.WattPerCubicMeter => baseUnitValue, + PowerDensityUnit.WattPerLiter => baseUnitValue/1.0e3, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerRatio.g.cs index c374d0b712..68944ed4d9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerRatio.g.cs @@ -142,13 +142,12 @@ public PowerRatio ToUnit(PowerRatioUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case PowerRatioUnit.DecibelMilliwatt: return _value - 30; - case PowerRatioUnit.DecibelWatt: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + PowerRatioUnit.DecibelMilliwatt => _value - 30, + PowerRatioUnit.DecibelWatt => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(PowerRatioUnit unit) @@ -158,13 +157,12 @@ private double GetValueAs(PowerRatioUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case PowerRatioUnit.DecibelMilliwatt: return baseUnitValue + 30; - case PowerRatioUnit.DecibelWatt: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + PowerRatioUnit.DecibelMilliwatt => baseUnitValue + 30, + PowerRatioUnit.DecibelWatt => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs index 259b7e8a30..cfd13bdd1f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs @@ -615,56 +615,55 @@ public Pressure ToUnit(PressureUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case PressureUnit.Atmosphere: return _value*1.01325*1e5; - case PressureUnit.Bar: return _value*1e5; - case PressureUnit.Centibar: return (_value*1e5) * 1e-2d; - case PressureUnit.Decapascal: return (_value) * 1e1d; - case PressureUnit.Decibar: return (_value*1e5) * 1e-1d; - case PressureUnit.DynePerSquareCentimeter: return _value*1.0e-1; - case PressureUnit.FootOfElevation: return Math.Pow(1.0 - (_value / 145366.45), 5.2553026003237266401799415610351) * 101325.0; - case PressureUnit.FootOfHead: return _value*2989.0669; - case PressureUnit.Gigapascal: return (_value) * 1e9d; - case PressureUnit.Hectopascal: return (_value) * 1e2d; - case PressureUnit.InchOfMercury: return _value/2.95299830714159e-4; - case PressureUnit.InchOfWaterColumn: return _value*249.08890833333; - case PressureUnit.Kilobar: return (_value*1e5) * 1e3d; - case PressureUnit.KilogramForcePerSquareCentimeter: return _value*9.80665e4; - case PressureUnit.KilogramForcePerSquareMeter: return _value*9.80665019960652; - case PressureUnit.KilogramForcePerSquareMillimeter: return _value*9.80665e6; - case PressureUnit.KilonewtonPerSquareCentimeter: return (_value*1e4) * 1e3d; - case PressureUnit.KilonewtonPerSquareMeter: return (_value) * 1e3d; - case PressureUnit.KilonewtonPerSquareMillimeter: return (_value*1e6) * 1e3d; - case PressureUnit.Kilopascal: return (_value) * 1e3d; - case PressureUnit.KilopoundForcePerSquareFoot: return (_value*4.788025898033584e1) * 1e3d; - case PressureUnit.KilopoundForcePerSquareInch: return (_value*6.894757293168361e3) * 1e3d; - case PressureUnit.Megabar: return (_value*1e5) * 1e6d; - case PressureUnit.MeganewtonPerSquareMeter: return (_value) * 1e6d; - case PressureUnit.Megapascal: return (_value) * 1e6d; - case PressureUnit.MeterOfElevation: return Math.Pow(1.0 - (_value / 44307.69396), 5.2553026003237266401799415610351) * 101325.0; - case PressureUnit.MeterOfHead: return _value*9804.139432; - case PressureUnit.Microbar: return (_value*1e5) * 1e-6d; - case PressureUnit.Micropascal: return (_value) * 1e-6d; - case PressureUnit.Millibar: return (_value*1e5) * 1e-3d; - case PressureUnit.MillimeterOfMercury: return _value/7.50061561302643e-3; - case PressureUnit.MillimeterOfWaterColumn: return _value*9.806650000000272e0; - case PressureUnit.Millipascal: return (_value) * 1e-3d; - case PressureUnit.NewtonPerSquareCentimeter: return _value*1e4; - case PressureUnit.NewtonPerSquareMeter: return _value; - case PressureUnit.NewtonPerSquareMillimeter: return _value*1e6; - case PressureUnit.Pascal: return _value; - case PressureUnit.PoundForcePerSquareFoot: return _value*4.788025898033584e1; - case PressureUnit.PoundForcePerSquareInch: return _value*6.894757293168361e3; - case PressureUnit.PoundPerInchSecondSquared: return _value*1.785796732283465e1; - case PressureUnit.TechnicalAtmosphere: return _value*9.80680592331*1e4; - case PressureUnit.TonneForcePerSquareCentimeter: return _value*9.80665e7; - case PressureUnit.TonneForcePerSquareMeter: return _value*9.80665e3; - case PressureUnit.TonneForcePerSquareMillimeter: return _value*9.80665e9; - case PressureUnit.Torr: return _value*1.3332266752*1e2; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + PressureUnit.Atmosphere => _value*1.01325*1e5, + PressureUnit.Bar => _value*1e5, + PressureUnit.Centibar => (_value*1e5) * 1e-2d, + PressureUnit.Decapascal => (_value) * 1e1d, + PressureUnit.Decibar => (_value*1e5) * 1e-1d, + PressureUnit.DynePerSquareCentimeter => _value*1.0e-1, + PressureUnit.FootOfElevation => Math.Pow(1.0 - (_value / 145366.45), 5.2553026003237266401799415610351) * 101325.0, + PressureUnit.FootOfHead => _value*2989.0669, + PressureUnit.Gigapascal => (_value) * 1e9d, + PressureUnit.Hectopascal => (_value) * 1e2d, + PressureUnit.InchOfMercury => _value/2.95299830714159e-4, + PressureUnit.InchOfWaterColumn => _value*249.08890833333, + PressureUnit.Kilobar => (_value*1e5) * 1e3d, + PressureUnit.KilogramForcePerSquareCentimeter => _value*9.80665e4, + PressureUnit.KilogramForcePerSquareMeter => _value*9.80665019960652, + PressureUnit.KilogramForcePerSquareMillimeter => _value*9.80665e6, + PressureUnit.KilonewtonPerSquareCentimeter => (_value*1e4) * 1e3d, + PressureUnit.KilonewtonPerSquareMeter => (_value) * 1e3d, + PressureUnit.KilonewtonPerSquareMillimeter => (_value*1e6) * 1e3d, + PressureUnit.Kilopascal => (_value) * 1e3d, + PressureUnit.KilopoundForcePerSquareFoot => (_value*4.788025898033584e1) * 1e3d, + PressureUnit.KilopoundForcePerSquareInch => (_value*6.894757293168361e3) * 1e3d, + PressureUnit.Megabar => (_value*1e5) * 1e6d, + PressureUnit.MeganewtonPerSquareMeter => (_value) * 1e6d, + PressureUnit.Megapascal => (_value) * 1e6d, + PressureUnit.MeterOfElevation => Math.Pow(1.0 - (_value / 44307.69396), 5.2553026003237266401799415610351) * 101325.0, + PressureUnit.MeterOfHead => _value*9804.139432, + PressureUnit.Microbar => (_value*1e5) * 1e-6d, + PressureUnit.Micropascal => (_value) * 1e-6d, + PressureUnit.Millibar => (_value*1e5) * 1e-3d, + PressureUnit.MillimeterOfMercury => _value/7.50061561302643e-3, + PressureUnit.MillimeterOfWaterColumn => _value*9.806650000000272e0, + PressureUnit.Millipascal => (_value) * 1e-3d, + PressureUnit.NewtonPerSquareCentimeter => _value*1e4, + PressureUnit.NewtonPerSquareMeter => _value, + PressureUnit.NewtonPerSquareMillimeter => _value*1e6, + PressureUnit.Pascal => _value, + PressureUnit.PoundForcePerSquareFoot => _value*4.788025898033584e1, + PressureUnit.PoundForcePerSquareInch => _value*6.894757293168361e3, + PressureUnit.PoundPerInchSecondSquared => _value*1.785796732283465e1, + PressureUnit.TechnicalAtmosphere => _value*9.80680592331*1e4, + PressureUnit.TonneForcePerSquareCentimeter => _value*9.80665e7, + PressureUnit.TonneForcePerSquareMeter => _value*9.80665e3, + PressureUnit.TonneForcePerSquareMillimeter => _value*9.80665e9, + PressureUnit.Torr => _value*1.3332266752*1e2, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(PressureUnit unit) @@ -674,56 +673,55 @@ private double GetValueAs(PressureUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case PressureUnit.Atmosphere: return baseUnitValue/(1.01325*1e5); - case PressureUnit.Bar: return baseUnitValue/1e5; - case PressureUnit.Centibar: return (baseUnitValue/1e5) / 1e-2d; - case PressureUnit.Decapascal: return (baseUnitValue) / 1e1d; - case PressureUnit.Decibar: return (baseUnitValue/1e5) / 1e-1d; - case PressureUnit.DynePerSquareCentimeter: return baseUnitValue/1.0e-1; - case PressureUnit.FootOfElevation: return (1.0 - Math.Pow(baseUnitValue / 101325.0, 0.190284)) * 145366.45; - case PressureUnit.FootOfHead: return baseUnitValue*0.000334552565551; - case PressureUnit.Gigapascal: return (baseUnitValue) / 1e9d; - case PressureUnit.Hectopascal: return (baseUnitValue) / 1e2d; - case PressureUnit.InchOfMercury: return baseUnitValue*2.95299830714159e-4; - case PressureUnit.InchOfWaterColumn: return baseUnitValue/249.08890833333; - case PressureUnit.Kilobar: return (baseUnitValue/1e5) / 1e3d; - case PressureUnit.KilogramForcePerSquareCentimeter: return baseUnitValue/9.80665e4; - case PressureUnit.KilogramForcePerSquareMeter: return baseUnitValue*0.101971619222242; - case PressureUnit.KilogramForcePerSquareMillimeter: return baseUnitValue/9.80665e6; - case PressureUnit.KilonewtonPerSquareCentimeter: return (baseUnitValue/1e4) / 1e3d; - case PressureUnit.KilonewtonPerSquareMeter: return (baseUnitValue) / 1e3d; - case PressureUnit.KilonewtonPerSquareMillimeter: return (baseUnitValue/1e6) / 1e3d; - case PressureUnit.Kilopascal: return (baseUnitValue) / 1e3d; - case PressureUnit.KilopoundForcePerSquareFoot: return (baseUnitValue/4.788025898033584e1) / 1e3d; - case PressureUnit.KilopoundForcePerSquareInch: return (baseUnitValue/6.894757293168361e3) / 1e3d; - case PressureUnit.Megabar: return (baseUnitValue/1e5) / 1e6d; - case PressureUnit.MeganewtonPerSquareMeter: return (baseUnitValue) / 1e6d; - case PressureUnit.Megapascal: return (baseUnitValue) / 1e6d; - case PressureUnit.MeterOfElevation: return (1.0 - Math.Pow(baseUnitValue / 101325.0, 0.190284)) * 44307.69396; - case PressureUnit.MeterOfHead: return baseUnitValue*0.0001019977334; - case PressureUnit.Microbar: return (baseUnitValue/1e5) / 1e-6d; - case PressureUnit.Micropascal: return (baseUnitValue) / 1e-6d; - case PressureUnit.Millibar: return (baseUnitValue/1e5) / 1e-3d; - case PressureUnit.MillimeterOfMercury: return baseUnitValue*7.50061561302643e-3; - case PressureUnit.MillimeterOfWaterColumn: return baseUnitValue/9.806650000000272e0; - case PressureUnit.Millipascal: return (baseUnitValue) / 1e-3d; - case PressureUnit.NewtonPerSquareCentimeter: return baseUnitValue/1e4; - case PressureUnit.NewtonPerSquareMeter: return baseUnitValue; - case PressureUnit.NewtonPerSquareMillimeter: return baseUnitValue/1e6; - case PressureUnit.Pascal: return baseUnitValue; - case PressureUnit.PoundForcePerSquareFoot: return baseUnitValue/4.788025898033584e1; - case PressureUnit.PoundForcePerSquareInch: return baseUnitValue/6.894757293168361e3; - case PressureUnit.PoundPerInchSecondSquared: return baseUnitValue/1.785796732283465e1; - case PressureUnit.TechnicalAtmosphere: return baseUnitValue/(9.80680592331*1e4); - case PressureUnit.TonneForcePerSquareCentimeter: return baseUnitValue/9.80665e7; - case PressureUnit.TonneForcePerSquareMeter: return baseUnitValue/9.80665e3; - case PressureUnit.TonneForcePerSquareMillimeter: return baseUnitValue/9.80665e9; - case PressureUnit.Torr: return baseUnitValue/(1.3332266752*1e2); - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + PressureUnit.Atmosphere => baseUnitValue/(1.01325*1e5), + PressureUnit.Bar => baseUnitValue/1e5, + PressureUnit.Centibar => (baseUnitValue/1e5) / 1e-2d, + PressureUnit.Decapascal => (baseUnitValue) / 1e1d, + PressureUnit.Decibar => (baseUnitValue/1e5) / 1e-1d, + PressureUnit.DynePerSquareCentimeter => baseUnitValue/1.0e-1, + PressureUnit.FootOfElevation => (1.0 - Math.Pow(baseUnitValue / 101325.0, 0.190284)) * 145366.45, + PressureUnit.FootOfHead => baseUnitValue*0.000334552565551, + PressureUnit.Gigapascal => (baseUnitValue) / 1e9d, + PressureUnit.Hectopascal => (baseUnitValue) / 1e2d, + PressureUnit.InchOfMercury => baseUnitValue*2.95299830714159e-4, + PressureUnit.InchOfWaterColumn => baseUnitValue/249.08890833333, + PressureUnit.Kilobar => (baseUnitValue/1e5) / 1e3d, + PressureUnit.KilogramForcePerSquareCentimeter => baseUnitValue/9.80665e4, + PressureUnit.KilogramForcePerSquareMeter => baseUnitValue*0.101971619222242, + PressureUnit.KilogramForcePerSquareMillimeter => baseUnitValue/9.80665e6, + PressureUnit.KilonewtonPerSquareCentimeter => (baseUnitValue/1e4) / 1e3d, + PressureUnit.KilonewtonPerSquareMeter => (baseUnitValue) / 1e3d, + PressureUnit.KilonewtonPerSquareMillimeter => (baseUnitValue/1e6) / 1e3d, + PressureUnit.Kilopascal => (baseUnitValue) / 1e3d, + PressureUnit.KilopoundForcePerSquareFoot => (baseUnitValue/4.788025898033584e1) / 1e3d, + PressureUnit.KilopoundForcePerSquareInch => (baseUnitValue/6.894757293168361e3) / 1e3d, + PressureUnit.Megabar => (baseUnitValue/1e5) / 1e6d, + PressureUnit.MeganewtonPerSquareMeter => (baseUnitValue) / 1e6d, + PressureUnit.Megapascal => (baseUnitValue) / 1e6d, + PressureUnit.MeterOfElevation => (1.0 - Math.Pow(baseUnitValue / 101325.0, 0.190284)) * 44307.69396, + PressureUnit.MeterOfHead => baseUnitValue*0.0001019977334, + PressureUnit.Microbar => (baseUnitValue/1e5) / 1e-6d, + PressureUnit.Micropascal => (baseUnitValue) / 1e-6d, + PressureUnit.Millibar => (baseUnitValue/1e5) / 1e-3d, + PressureUnit.MillimeterOfMercury => baseUnitValue*7.50061561302643e-3, + PressureUnit.MillimeterOfWaterColumn => baseUnitValue/9.806650000000272e0, + PressureUnit.Millipascal => (baseUnitValue) / 1e-3d, + PressureUnit.NewtonPerSquareCentimeter => baseUnitValue/1e4, + PressureUnit.NewtonPerSquareMeter => baseUnitValue, + PressureUnit.NewtonPerSquareMillimeter => baseUnitValue/1e6, + PressureUnit.Pascal => baseUnitValue, + PressureUnit.PoundForcePerSquareFoot => baseUnitValue/4.788025898033584e1, + PressureUnit.PoundForcePerSquareInch => baseUnitValue/6.894757293168361e3, + PressureUnit.PoundPerInchSecondSquared => baseUnitValue/1.785796732283465e1, + PressureUnit.TechnicalAtmosphere => baseUnitValue/(9.80680592331*1e4), + PressureUnit.TonneForcePerSquareCentimeter => baseUnitValue/9.80665e7, + PressureUnit.TonneForcePerSquareMeter => baseUnitValue/9.80665e3, + PressureUnit.TonneForcePerSquareMillimeter => baseUnitValue/9.80665e9, + PressureUnit.Torr => baseUnitValue/(1.3332266752*1e2), + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PressureChangeRate.g.cs index 4ff1675495..187253c829 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -274,25 +274,24 @@ public PressureChangeRate ToUnit(PressureChangeRateUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case PressureChangeRateUnit.AtmospherePerSecond: return _value * 1.01325*1e5; - case PressureChangeRateUnit.KilopascalPerMinute: return (_value/60) * 1e3d; - case PressureChangeRateUnit.KilopascalPerSecond: return (_value) * 1e3d; - case PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute: return (_value*6.894757293168361e3/60) * 1e3d; - case PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond: return (_value*6.894757293168361e3) * 1e3d; - case PressureChangeRateUnit.MegapascalPerMinute: return (_value/60) * 1e6d; - case PressureChangeRateUnit.MegapascalPerSecond: return (_value) * 1e6d; - case PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute: return (_value*6.894757293168361e3/60) * 1e6d; - case PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond: return (_value*6.894757293168361e3) * 1e6d; - case PressureChangeRateUnit.MillimeterOfMercuryPerSecond: return _value*133.322; - case PressureChangeRateUnit.PascalPerMinute: return _value/60; - case PressureChangeRateUnit.PascalPerSecond: return _value; - case PressureChangeRateUnit.PoundForcePerSquareInchPerMinute: return _value*6.894757293168361e3/60; - case PressureChangeRateUnit.PoundForcePerSquareInchPerSecond: return _value*6.894757293168361e3; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + PressureChangeRateUnit.AtmospherePerSecond => _value * 1.01325*1e5, + PressureChangeRateUnit.KilopascalPerMinute => (_value/60) * 1e3d, + PressureChangeRateUnit.KilopascalPerSecond => (_value) * 1e3d, + PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute => (_value*6.894757293168361e3/60) * 1e3d, + PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond => (_value*6.894757293168361e3) * 1e3d, + PressureChangeRateUnit.MegapascalPerMinute => (_value/60) * 1e6d, + PressureChangeRateUnit.MegapascalPerSecond => (_value) * 1e6d, + PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute => (_value*6.894757293168361e3/60) * 1e6d, + PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond => (_value*6.894757293168361e3) * 1e6d, + PressureChangeRateUnit.MillimeterOfMercuryPerSecond => _value*133.322, + PressureChangeRateUnit.PascalPerMinute => _value/60, + PressureChangeRateUnit.PascalPerSecond => _value, + PressureChangeRateUnit.PoundForcePerSquareInchPerMinute => _value*6.894757293168361e3/60, + PressureChangeRateUnit.PoundForcePerSquareInchPerSecond => _value*6.894757293168361e3, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(PressureChangeRateUnit unit) @@ -302,25 +301,24 @@ private double GetValueAs(PressureChangeRateUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case PressureChangeRateUnit.AtmospherePerSecond: return baseUnitValue / (1.01325*1e5); - case PressureChangeRateUnit.KilopascalPerMinute: return (baseUnitValue*60) / 1e3d; - case PressureChangeRateUnit.KilopascalPerSecond: return (baseUnitValue) / 1e3d; - case PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute: return (baseUnitValue/6.894757293168361e3*60) / 1e3d; - case PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond: return (baseUnitValue/6.894757293168361e3) / 1e3d; - case PressureChangeRateUnit.MegapascalPerMinute: return (baseUnitValue*60) / 1e6d; - case PressureChangeRateUnit.MegapascalPerSecond: return (baseUnitValue) / 1e6d; - case PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute: return (baseUnitValue/6.894757293168361e3*60) / 1e6d; - case PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond: return (baseUnitValue/6.894757293168361e3) / 1e6d; - case PressureChangeRateUnit.MillimeterOfMercuryPerSecond: return baseUnitValue/133.322; - case PressureChangeRateUnit.PascalPerMinute: return baseUnitValue*60; - case PressureChangeRateUnit.PascalPerSecond: return baseUnitValue; - case PressureChangeRateUnit.PoundForcePerSquareInchPerMinute: return baseUnitValue/6.894757293168361e3*60; - case PressureChangeRateUnit.PoundForcePerSquareInchPerSecond: return baseUnitValue/6.894757293168361e3; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + PressureChangeRateUnit.AtmospherePerSecond => baseUnitValue / (1.01325*1e5), + PressureChangeRateUnit.KilopascalPerMinute => (baseUnitValue*60) / 1e3d, + PressureChangeRateUnit.KilopascalPerSecond => (baseUnitValue) / 1e3d, + PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute => (baseUnitValue/6.894757293168361e3*60) / 1e3d, + PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond => (baseUnitValue/6.894757293168361e3) / 1e3d, + PressureChangeRateUnit.MegapascalPerMinute => (baseUnitValue*60) / 1e6d, + PressureChangeRateUnit.MegapascalPerSecond => (baseUnitValue) / 1e6d, + PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute => (baseUnitValue/6.894757293168361e3*60) / 1e6d, + PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond => (baseUnitValue/6.894757293168361e3) / 1e6d, + PressureChangeRateUnit.MillimeterOfMercuryPerSecond => baseUnitValue/133.322, + PressureChangeRateUnit.PascalPerMinute => baseUnitValue*60, + PressureChangeRateUnit.PascalPerSecond => baseUnitValue, + PressureChangeRateUnit.PoundForcePerSquareInchPerMinute => baseUnitValue/6.894757293168361e3*60, + PressureChangeRateUnit.PoundForcePerSquareInchPerSecond => baseUnitValue/6.894757293168361e3, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Ratio.g.cs index 49a2e9d28f..b23cd6e09d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Ratio.g.cs @@ -186,17 +186,16 @@ public Ratio ToUnit(RatioUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case RatioUnit.DecimalFraction: return _value; - case RatioUnit.PartPerBillion: return _value/1e9; - case RatioUnit.PartPerMillion: return _value/1e6; - case RatioUnit.PartPerThousand: return _value/1e3; - case RatioUnit.PartPerTrillion: return _value/1e12; - case RatioUnit.Percent: return _value/1e2; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + RatioUnit.DecimalFraction => _value, + RatioUnit.PartPerBillion => _value/1e9, + RatioUnit.PartPerMillion => _value/1e6, + RatioUnit.PartPerThousand => _value/1e3, + RatioUnit.PartPerTrillion => _value/1e12, + RatioUnit.Percent => _value/1e2, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(RatioUnit unit) @@ -206,17 +205,16 @@ private double GetValueAs(RatioUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case RatioUnit.DecimalFraction: return baseUnitValue; - case RatioUnit.PartPerBillion: return baseUnitValue*1e9; - case RatioUnit.PartPerMillion: return baseUnitValue*1e6; - case RatioUnit.PartPerThousand: return baseUnitValue*1e3; - case RatioUnit.PartPerTrillion: return baseUnitValue*1e12; - case RatioUnit.Percent: return baseUnitValue*1e2; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + RatioUnit.DecimalFraction => baseUnitValue, + RatioUnit.PartPerBillion => baseUnitValue*1e9, + RatioUnit.PartPerMillion => baseUnitValue*1e6, + RatioUnit.PartPerThousand => baseUnitValue*1e3, + RatioUnit.PartPerTrillion => baseUnitValue*1e12, + RatioUnit.Percent => baseUnitValue*1e2, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RatioChangeRate.g.cs index 5ea01f41a5..d4fa59d81e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -142,13 +142,12 @@ public RatioChangeRate ToUnit(RatioChangeRateUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case RatioChangeRateUnit.DecimalFractionPerSecond: return _value; - case RatioChangeRateUnit.PercentPerSecond: return _value/1e2; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + RatioChangeRateUnit.DecimalFractionPerSecond => _value, + RatioChangeRateUnit.PercentPerSecond => _value/1e2, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(RatioChangeRateUnit unit) @@ -158,13 +157,12 @@ private double GetValueAs(RatioChangeRateUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case RatioChangeRateUnit.DecimalFractionPerSecond: return baseUnitValue; - case RatioChangeRateUnit.PercentPerSecond: return baseUnitValue*1e2; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + RatioChangeRateUnit.DecimalFractionPerSecond => baseUnitValue, + RatioChangeRateUnit.PercentPerSecond => baseUnitValue*1e2, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactiveEnergy.g.cs index 0f59ca7797..c3e089c7e8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -153,14 +153,13 @@ public ReactiveEnergy ToUnit(ReactiveEnergyUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ReactiveEnergyUnit.KilovoltampereReactiveHour: return (_value) * 1e3d; - case ReactiveEnergyUnit.MegavoltampereReactiveHour: return (_value) * 1e6d; - case ReactiveEnergyUnit.VoltampereReactiveHour: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ReactiveEnergyUnit.KilovoltampereReactiveHour => (_value) * 1e3d, + ReactiveEnergyUnit.MegavoltampereReactiveHour => (_value) * 1e6d, + ReactiveEnergyUnit.VoltampereReactiveHour => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ReactiveEnergyUnit unit) @@ -170,14 +169,13 @@ private double GetValueAs(ReactiveEnergyUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ReactiveEnergyUnit.KilovoltampereReactiveHour: return (baseUnitValue) / 1e3d; - case ReactiveEnergyUnit.MegavoltampereReactiveHour: return (baseUnitValue) / 1e6d; - case ReactiveEnergyUnit.VoltampereReactiveHour: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ReactiveEnergyUnit.KilovoltampereReactiveHour => (baseUnitValue) / 1e3d, + ReactiveEnergyUnit.MegavoltampereReactiveHour => (baseUnitValue) / 1e6d, + ReactiveEnergyUnit.VoltampereReactiveHour => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactivePower.g.cs index 100faa396f..fcb77dcc3a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactivePower.g.cs @@ -164,15 +164,14 @@ public ReactivePower ToUnit(ReactivePowerUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ReactivePowerUnit.GigavoltampereReactive: return (_value) * 1e9d; - case ReactivePowerUnit.KilovoltampereReactive: return (_value) * 1e3d; - case ReactivePowerUnit.MegavoltampereReactive: return (_value) * 1e6d; - case ReactivePowerUnit.VoltampereReactive: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ReactivePowerUnit.GigavoltampereReactive => (_value) * 1e9d, + ReactivePowerUnit.KilovoltampereReactive => (_value) * 1e3d, + ReactivePowerUnit.MegavoltampereReactive => (_value) * 1e6d, + ReactivePowerUnit.VoltampereReactive => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ReactivePowerUnit unit) @@ -182,15 +181,14 @@ private double GetValueAs(ReactivePowerUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ReactivePowerUnit.GigavoltampereReactive: return (baseUnitValue) / 1e9d; - case ReactivePowerUnit.KilovoltampereReactive: return (baseUnitValue) / 1e3d; - case ReactivePowerUnit.MegavoltampereReactive: return (baseUnitValue) / 1e6d; - case ReactivePowerUnit.VoltampereReactive: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ReactivePowerUnit.GigavoltampereReactive => (baseUnitValue) / 1e9d, + ReactivePowerUnit.KilovoltampereReactive => (baseUnitValue) / 1e3d, + ReactivePowerUnit.MegavoltampereReactive => (baseUnitValue) / 1e6d, + ReactivePowerUnit.VoltampereReactive => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalArea.g.cs index 36e47708f4..37826e8426 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -244,22 +244,21 @@ public ReciprocalArea ToUnit(ReciprocalAreaUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ReciprocalAreaUnit.InverseSquareCentimeter: return _value/1e-4; - case ReciprocalAreaUnit.InverseSquareDecimeter: return _value/1e-2; - case ReciprocalAreaUnit.InverseSquareFoot: return _value/0.092903; - case ReciprocalAreaUnit.InverseSquareInch: return _value/0.00064516; - case ReciprocalAreaUnit.InverseSquareKilometer: return _value/1e6; - case ReciprocalAreaUnit.InverseSquareMeter: return _value; - case ReciprocalAreaUnit.InverseSquareMicrometer: return _value/1e-12; - case ReciprocalAreaUnit.InverseSquareMile: return _value/2.59e6; - case ReciprocalAreaUnit.InverseSquareMillimeter: return _value/1e-6; - case ReciprocalAreaUnit.InverseSquareYard: return _value/0.836127; - case ReciprocalAreaUnit.InverseUsSurveySquareFoot: return _value/0.09290341161; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ReciprocalAreaUnit.InverseSquareCentimeter => _value/1e-4, + ReciprocalAreaUnit.InverseSquareDecimeter => _value/1e-2, + ReciprocalAreaUnit.InverseSquareFoot => _value/0.092903, + ReciprocalAreaUnit.InverseSquareInch => _value/0.00064516, + ReciprocalAreaUnit.InverseSquareKilometer => _value/1e6, + ReciprocalAreaUnit.InverseSquareMeter => _value, + ReciprocalAreaUnit.InverseSquareMicrometer => _value/1e-12, + ReciprocalAreaUnit.InverseSquareMile => _value/2.59e6, + ReciprocalAreaUnit.InverseSquareMillimeter => _value/1e-6, + ReciprocalAreaUnit.InverseSquareYard => _value/0.836127, + ReciprocalAreaUnit.InverseUsSurveySquareFoot => _value/0.09290341161, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ReciprocalAreaUnit unit) @@ -269,22 +268,21 @@ private double GetValueAs(ReciprocalAreaUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ReciprocalAreaUnit.InverseSquareCentimeter: return baseUnitValue*1e-4; - case ReciprocalAreaUnit.InverseSquareDecimeter: return baseUnitValue*1e-2; - case ReciprocalAreaUnit.InverseSquareFoot: return baseUnitValue*0.092903; - case ReciprocalAreaUnit.InverseSquareInch: return baseUnitValue*0.00064516; - case ReciprocalAreaUnit.InverseSquareKilometer: return baseUnitValue*1e6; - case ReciprocalAreaUnit.InverseSquareMeter: return baseUnitValue; - case ReciprocalAreaUnit.InverseSquareMicrometer: return baseUnitValue*1e-12; - case ReciprocalAreaUnit.InverseSquareMile: return baseUnitValue*2.59e6; - case ReciprocalAreaUnit.InverseSquareMillimeter: return baseUnitValue*1e-6; - case ReciprocalAreaUnit.InverseSquareYard: return baseUnitValue*0.836127; - case ReciprocalAreaUnit.InverseUsSurveySquareFoot: return baseUnitValue*0.09290341161; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ReciprocalAreaUnit.InverseSquareCentimeter => baseUnitValue*1e-4, + ReciprocalAreaUnit.InverseSquareDecimeter => baseUnitValue*1e-2, + ReciprocalAreaUnit.InverseSquareFoot => baseUnitValue*0.092903, + ReciprocalAreaUnit.InverseSquareInch => baseUnitValue*0.00064516, + ReciprocalAreaUnit.InverseSquareKilometer => baseUnitValue*1e6, + ReciprocalAreaUnit.InverseSquareMeter => baseUnitValue, + ReciprocalAreaUnit.InverseSquareMicrometer => baseUnitValue*1e-12, + ReciprocalAreaUnit.InverseSquareMile => baseUnitValue*2.59e6, + ReciprocalAreaUnit.InverseSquareMillimeter => baseUnitValue*1e-6, + ReciprocalAreaUnit.InverseSquareYard => baseUnitValue*0.836127, + ReciprocalAreaUnit.InverseUsSurveySquareFoot => baseUnitValue*0.09290341161, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalLength.g.cs index 8253de01c1..bf2c263fb1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -233,21 +233,20 @@ public ReciprocalLength ToUnit(ReciprocalLengthUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ReciprocalLengthUnit.InverseCentimeter: return _value*1e2; - case ReciprocalLengthUnit.InverseFoot: return _value/0.3048; - case ReciprocalLengthUnit.InverseInch: return _value/2.54e-2; - case ReciprocalLengthUnit.InverseMeter: return _value; - case ReciprocalLengthUnit.InverseMicroinch: return _value/2.54e-8; - case ReciprocalLengthUnit.InverseMil: return _value/2.54e-5; - case ReciprocalLengthUnit.InverseMile: return _value/1609.34; - case ReciprocalLengthUnit.InverseMillimeter: return _value*1e3; - case ReciprocalLengthUnit.InverseUsSurveyFoot: return _value*3937/1200; - case ReciprocalLengthUnit.InverseYard: return _value/0.9144; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ReciprocalLengthUnit.InverseCentimeter => _value*1e2, + ReciprocalLengthUnit.InverseFoot => _value/0.3048, + ReciprocalLengthUnit.InverseInch => _value/2.54e-2, + ReciprocalLengthUnit.InverseMeter => _value, + ReciprocalLengthUnit.InverseMicroinch => _value/2.54e-8, + ReciprocalLengthUnit.InverseMil => _value/2.54e-5, + ReciprocalLengthUnit.InverseMile => _value/1609.34, + ReciprocalLengthUnit.InverseMillimeter => _value*1e3, + ReciprocalLengthUnit.InverseUsSurveyFoot => _value*3937/1200, + ReciprocalLengthUnit.InverseYard => _value/0.9144, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ReciprocalLengthUnit unit) @@ -257,21 +256,20 @@ private double GetValueAs(ReciprocalLengthUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ReciprocalLengthUnit.InverseCentimeter: return baseUnitValue/1e2; - case ReciprocalLengthUnit.InverseFoot: return baseUnitValue*0.3048; - case ReciprocalLengthUnit.InverseInch: return baseUnitValue*2.54e-2; - case ReciprocalLengthUnit.InverseMeter: return baseUnitValue; - case ReciprocalLengthUnit.InverseMicroinch: return baseUnitValue*2.54e-8; - case ReciprocalLengthUnit.InverseMil: return baseUnitValue*2.54e-5; - case ReciprocalLengthUnit.InverseMile: return baseUnitValue*1609.34; - case ReciprocalLengthUnit.InverseMillimeter: return baseUnitValue/1e3; - case ReciprocalLengthUnit.InverseUsSurveyFoot: return baseUnitValue*1200/3937; - case ReciprocalLengthUnit.InverseYard: return baseUnitValue*0.9144; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ReciprocalLengthUnit.InverseCentimeter => baseUnitValue/1e2, + ReciprocalLengthUnit.InverseFoot => baseUnitValue*0.3048, + ReciprocalLengthUnit.InverseInch => baseUnitValue*2.54e-2, + ReciprocalLengthUnit.InverseMeter => baseUnitValue, + ReciprocalLengthUnit.InverseMicroinch => baseUnitValue*2.54e-8, + ReciprocalLengthUnit.InverseMil => baseUnitValue*2.54e-5, + ReciprocalLengthUnit.InverseMile => baseUnitValue*1609.34, + ReciprocalLengthUnit.InverseMillimeter => baseUnitValue/1e3, + ReciprocalLengthUnit.InverseUsSurveyFoot => baseUnitValue*1200/3937, + ReciprocalLengthUnit.InverseYard => baseUnitValue*0.9144, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RelativeHumidity.g.cs index ed69e747bf..f3cc30759d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -131,12 +131,11 @@ public RelativeHumidity ToUnit(RelativeHumidityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case RelativeHumidityUnit.Percent: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + RelativeHumidityUnit.Percent => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(RelativeHumidityUnit unit) @@ -146,12 +145,11 @@ private double GetValueAs(RelativeHumidityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case RelativeHumidityUnit.Percent: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + RelativeHumidityUnit.Percent => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 782a1743ec..a36e8e745b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -164,15 +164,14 @@ public RotationalAcceleration ToUnit(RotationalAccelerationUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case RotationalAccelerationUnit.DegreePerSecondSquared: return (3.1415926535897931/180)*_value; - case RotationalAccelerationUnit.RadianPerSecondSquared: return _value; - case RotationalAccelerationUnit.RevolutionPerMinutePerSecond: return ((2*3.1415926535897931)/60)*_value; - case RotationalAccelerationUnit.RevolutionPerSecondSquared: return (2*3.1415926535897931)*_value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + RotationalAccelerationUnit.DegreePerSecondSquared => (3.1415926535897931/180)*_value, + RotationalAccelerationUnit.RadianPerSecondSquared => _value, + RotationalAccelerationUnit.RevolutionPerMinutePerSecond => ((2*3.1415926535897931)/60)*_value, + RotationalAccelerationUnit.RevolutionPerSecondSquared => (2*3.1415926535897931)*_value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(RotationalAccelerationUnit unit) @@ -182,15 +181,14 @@ private double GetValueAs(RotationalAccelerationUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case RotationalAccelerationUnit.DegreePerSecondSquared: return (180/3.1415926535897931)*baseUnitValue; - case RotationalAccelerationUnit.RadianPerSecondSquared: return baseUnitValue; - case RotationalAccelerationUnit.RevolutionPerMinutePerSecond: return (60/(2*3.1415926535897931))*baseUnitValue; - case RotationalAccelerationUnit.RevolutionPerSecondSquared: return (1/(2*3.1415926535897931))*baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + RotationalAccelerationUnit.DegreePerSecondSquared => (180/3.1415926535897931)*baseUnitValue, + RotationalAccelerationUnit.RadianPerSecondSquared => baseUnitValue, + RotationalAccelerationUnit.RevolutionPerMinutePerSecond => (60/(2*3.1415926535897931))*baseUnitValue, + RotationalAccelerationUnit.RevolutionPerSecondSquared => (1/(2*3.1415926535897931))*baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalSpeed.g.cs index 6073d25e12..296c652175 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -263,24 +263,23 @@ public RotationalSpeed ToUnit(RotationalSpeedUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case RotationalSpeedUnit.CentiradianPerSecond: return (_value) * 1e-2d; - case RotationalSpeedUnit.DeciradianPerSecond: return (_value) * 1e-1d; - case RotationalSpeedUnit.DegreePerMinute: return (3.1415926535897931/(180*60))*_value; - case RotationalSpeedUnit.DegreePerSecond: return (3.1415926535897931/180)*_value; - case RotationalSpeedUnit.MicrodegreePerSecond: return ((3.1415926535897931/180)*_value) * 1e-6d; - case RotationalSpeedUnit.MicroradianPerSecond: return (_value) * 1e-6d; - case RotationalSpeedUnit.MillidegreePerSecond: return ((3.1415926535897931/180)*_value) * 1e-3d; - case RotationalSpeedUnit.MilliradianPerSecond: return (_value) * 1e-3d; - case RotationalSpeedUnit.NanodegreePerSecond: return ((3.1415926535897931/180)*_value) * 1e-9d; - case RotationalSpeedUnit.NanoradianPerSecond: return (_value) * 1e-9d; - case RotationalSpeedUnit.RadianPerSecond: return _value; - case RotationalSpeedUnit.RevolutionPerMinute: return (_value*6.2831853072)/60; - case RotationalSpeedUnit.RevolutionPerSecond: return _value*6.2831853072; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + RotationalSpeedUnit.CentiradianPerSecond => (_value) * 1e-2d, + RotationalSpeedUnit.DeciradianPerSecond => (_value) * 1e-1d, + RotationalSpeedUnit.DegreePerMinute => (3.1415926535897931/(180*60))*_value, + RotationalSpeedUnit.DegreePerSecond => (3.1415926535897931/180)*_value, + RotationalSpeedUnit.MicrodegreePerSecond => ((3.1415926535897931/180)*_value) * 1e-6d, + RotationalSpeedUnit.MicroradianPerSecond => (_value) * 1e-6d, + RotationalSpeedUnit.MillidegreePerSecond => ((3.1415926535897931/180)*_value) * 1e-3d, + RotationalSpeedUnit.MilliradianPerSecond => (_value) * 1e-3d, + RotationalSpeedUnit.NanodegreePerSecond => ((3.1415926535897931/180)*_value) * 1e-9d, + RotationalSpeedUnit.NanoradianPerSecond => (_value) * 1e-9d, + RotationalSpeedUnit.RadianPerSecond => _value, + RotationalSpeedUnit.RevolutionPerMinute => (_value*6.2831853072)/60, + RotationalSpeedUnit.RevolutionPerSecond => _value*6.2831853072, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(RotationalSpeedUnit unit) @@ -290,24 +289,23 @@ private double GetValueAs(RotationalSpeedUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case RotationalSpeedUnit.CentiradianPerSecond: return (baseUnitValue) / 1e-2d; - case RotationalSpeedUnit.DeciradianPerSecond: return (baseUnitValue) / 1e-1d; - case RotationalSpeedUnit.DegreePerMinute: return (180*60/3.1415926535897931)*baseUnitValue; - case RotationalSpeedUnit.DegreePerSecond: return (180/3.1415926535897931)*baseUnitValue; - case RotationalSpeedUnit.MicrodegreePerSecond: return ((180/3.1415926535897931)*baseUnitValue) / 1e-6d; - case RotationalSpeedUnit.MicroradianPerSecond: return (baseUnitValue) / 1e-6d; - case RotationalSpeedUnit.MillidegreePerSecond: return ((180/3.1415926535897931)*baseUnitValue) / 1e-3d; - case RotationalSpeedUnit.MilliradianPerSecond: return (baseUnitValue) / 1e-3d; - case RotationalSpeedUnit.NanodegreePerSecond: return ((180/3.1415926535897931)*baseUnitValue) / 1e-9d; - case RotationalSpeedUnit.NanoradianPerSecond: return (baseUnitValue) / 1e-9d; - case RotationalSpeedUnit.RadianPerSecond: return baseUnitValue; - case RotationalSpeedUnit.RevolutionPerMinute: return (baseUnitValue/6.2831853072)*60; - case RotationalSpeedUnit.RevolutionPerSecond: return baseUnitValue/6.2831853072; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + RotationalSpeedUnit.CentiradianPerSecond => (baseUnitValue) / 1e-2d, + RotationalSpeedUnit.DeciradianPerSecond => (baseUnitValue) / 1e-1d, + RotationalSpeedUnit.DegreePerMinute => (180*60/3.1415926535897931)*baseUnitValue, + RotationalSpeedUnit.DegreePerSecond => (180/3.1415926535897931)*baseUnitValue, + RotationalSpeedUnit.MicrodegreePerSecond => ((180/3.1415926535897931)*baseUnitValue) / 1e-6d, + RotationalSpeedUnit.MicroradianPerSecond => (baseUnitValue) / 1e-6d, + RotationalSpeedUnit.MillidegreePerSecond => ((180/3.1415926535897931)*baseUnitValue) / 1e-3d, + RotationalSpeedUnit.MilliradianPerSecond => (baseUnitValue) / 1e-3d, + RotationalSpeedUnit.NanodegreePerSecond => ((180/3.1415926535897931)*baseUnitValue) / 1e-9d, + RotationalSpeedUnit.NanoradianPerSecond => (baseUnitValue) / 1e-9d, + RotationalSpeedUnit.RadianPerSecond => baseUnitValue, + RotationalSpeedUnit.RevolutionPerMinute => (baseUnitValue/6.2831853072)*60, + RotationalSpeedUnit.RevolutionPerSecond => baseUnitValue/6.2831853072, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffness.g.cs index 593c7614f4..021440fe36 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -483,44 +483,43 @@ public RotationalStiffness ToUnit(RotationalStiffnessUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case RotationalStiffnessUnit.CentinewtonMeterPerDegree: return (_value*(180/3.1415926535897931)) * 1e-2d; - case RotationalStiffnessUnit.CentinewtonMillimeterPerDegree: return (_value*180/3.1415926535897931*0.001) * 1e-2d; - case RotationalStiffnessUnit.CentinewtonMillimeterPerRadian: return (_value*0.001) * 1e-2d; - case RotationalStiffnessUnit.DecanewtonMeterPerDegree: return (_value*(180/3.1415926535897931)) * 1e1d; - case RotationalStiffnessUnit.DecanewtonMillimeterPerDegree: return (_value*180/3.1415926535897931*0.001) * 1e1d; - case RotationalStiffnessUnit.DecanewtonMillimeterPerRadian: return (_value*0.001) * 1e1d; - case RotationalStiffnessUnit.DecinewtonMeterPerDegree: return (_value*(180/3.1415926535897931)) * 1e-1d; - case RotationalStiffnessUnit.DecinewtonMillimeterPerDegree: return (_value*180/3.1415926535897931*0.001) * 1e-1d; - case RotationalStiffnessUnit.DecinewtonMillimeterPerRadian: return (_value*0.001) * 1e-1d; - case RotationalStiffnessUnit.KilonewtonMeterPerDegree: return (_value*(180/3.1415926535897931)) * 1e3d; - case RotationalStiffnessUnit.KilonewtonMeterPerRadian: return (_value) * 1e3d; - case RotationalStiffnessUnit.KilonewtonMillimeterPerDegree: return (_value*180/3.1415926535897931*0.001) * 1e3d; - case RotationalStiffnessUnit.KilonewtonMillimeterPerRadian: return (_value*0.001) * 1e3d; - case RotationalStiffnessUnit.KilopoundForceFootPerDegrees: return _value*77682.6; - case RotationalStiffnessUnit.MeganewtonMeterPerDegree: return (_value*(180/3.1415926535897931)) * 1e6d; - case RotationalStiffnessUnit.MeganewtonMeterPerRadian: return (_value) * 1e6d; - case RotationalStiffnessUnit.MeganewtonMillimeterPerDegree: return (_value*180/3.1415926535897931*0.001) * 1e6d; - case RotationalStiffnessUnit.MeganewtonMillimeterPerRadian: return (_value*0.001) * 1e6d; - case RotationalStiffnessUnit.MicronewtonMeterPerDegree: return (_value*(180/3.1415926535897931)) * 1e-6d; - case RotationalStiffnessUnit.MicronewtonMillimeterPerDegree: return (_value*180/3.1415926535897931*0.001) * 1e-6d; - case RotationalStiffnessUnit.MicronewtonMillimeterPerRadian: return (_value*0.001) * 1e-6d; - case RotationalStiffnessUnit.MillinewtonMeterPerDegree: return (_value*(180/3.1415926535897931)) * 1e-3d; - case RotationalStiffnessUnit.MillinewtonMillimeterPerDegree: return (_value*180/3.1415926535897931*0.001) * 1e-3d; - case RotationalStiffnessUnit.MillinewtonMillimeterPerRadian: return (_value*0.001) * 1e-3d; - case RotationalStiffnessUnit.NanonewtonMeterPerDegree: return (_value*(180/3.1415926535897931)) * 1e-9d; - case RotationalStiffnessUnit.NanonewtonMillimeterPerDegree: return (_value*180/3.1415926535897931*0.001) * 1e-9d; - case RotationalStiffnessUnit.NanonewtonMillimeterPerRadian: return (_value*0.001) * 1e-9d; - case RotationalStiffnessUnit.NewtonMeterPerDegree: return _value*(180/3.1415926535897931); - case RotationalStiffnessUnit.NewtonMeterPerRadian: return _value; - case RotationalStiffnessUnit.NewtonMillimeterPerDegree: return _value*180/3.1415926535897931*0.001; - case RotationalStiffnessUnit.NewtonMillimeterPerRadian: return _value*0.001; - case RotationalStiffnessUnit.PoundForceFeetPerRadian: return _value*1.3558179483314; - case RotationalStiffnessUnit.PoundForceFootPerDegrees: return _value*77.6826; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + RotationalStiffnessUnit.CentinewtonMeterPerDegree => (_value*(180/3.1415926535897931)) * 1e-2d, + RotationalStiffnessUnit.CentinewtonMillimeterPerDegree => (_value*180/3.1415926535897931*0.001) * 1e-2d, + RotationalStiffnessUnit.CentinewtonMillimeterPerRadian => (_value*0.001) * 1e-2d, + RotationalStiffnessUnit.DecanewtonMeterPerDegree => (_value*(180/3.1415926535897931)) * 1e1d, + RotationalStiffnessUnit.DecanewtonMillimeterPerDegree => (_value*180/3.1415926535897931*0.001) * 1e1d, + RotationalStiffnessUnit.DecanewtonMillimeterPerRadian => (_value*0.001) * 1e1d, + RotationalStiffnessUnit.DecinewtonMeterPerDegree => (_value*(180/3.1415926535897931)) * 1e-1d, + RotationalStiffnessUnit.DecinewtonMillimeterPerDegree => (_value*180/3.1415926535897931*0.001) * 1e-1d, + RotationalStiffnessUnit.DecinewtonMillimeterPerRadian => (_value*0.001) * 1e-1d, + RotationalStiffnessUnit.KilonewtonMeterPerDegree => (_value*(180/3.1415926535897931)) * 1e3d, + RotationalStiffnessUnit.KilonewtonMeterPerRadian => (_value) * 1e3d, + RotationalStiffnessUnit.KilonewtonMillimeterPerDegree => (_value*180/3.1415926535897931*0.001) * 1e3d, + RotationalStiffnessUnit.KilonewtonMillimeterPerRadian => (_value*0.001) * 1e3d, + RotationalStiffnessUnit.KilopoundForceFootPerDegrees => _value*77682.6, + RotationalStiffnessUnit.MeganewtonMeterPerDegree => (_value*(180/3.1415926535897931)) * 1e6d, + RotationalStiffnessUnit.MeganewtonMeterPerRadian => (_value) * 1e6d, + RotationalStiffnessUnit.MeganewtonMillimeterPerDegree => (_value*180/3.1415926535897931*0.001) * 1e6d, + RotationalStiffnessUnit.MeganewtonMillimeterPerRadian => (_value*0.001) * 1e6d, + RotationalStiffnessUnit.MicronewtonMeterPerDegree => (_value*(180/3.1415926535897931)) * 1e-6d, + RotationalStiffnessUnit.MicronewtonMillimeterPerDegree => (_value*180/3.1415926535897931*0.001) * 1e-6d, + RotationalStiffnessUnit.MicronewtonMillimeterPerRadian => (_value*0.001) * 1e-6d, + RotationalStiffnessUnit.MillinewtonMeterPerDegree => (_value*(180/3.1415926535897931)) * 1e-3d, + RotationalStiffnessUnit.MillinewtonMillimeterPerDegree => (_value*180/3.1415926535897931*0.001) * 1e-3d, + RotationalStiffnessUnit.MillinewtonMillimeterPerRadian => (_value*0.001) * 1e-3d, + RotationalStiffnessUnit.NanonewtonMeterPerDegree => (_value*(180/3.1415926535897931)) * 1e-9d, + RotationalStiffnessUnit.NanonewtonMillimeterPerDegree => (_value*180/3.1415926535897931*0.001) * 1e-9d, + RotationalStiffnessUnit.NanonewtonMillimeterPerRadian => (_value*0.001) * 1e-9d, + RotationalStiffnessUnit.NewtonMeterPerDegree => _value*(180/3.1415926535897931), + RotationalStiffnessUnit.NewtonMeterPerRadian => _value, + RotationalStiffnessUnit.NewtonMillimeterPerDegree => _value*180/3.1415926535897931*0.001, + RotationalStiffnessUnit.NewtonMillimeterPerRadian => _value*0.001, + RotationalStiffnessUnit.PoundForceFeetPerRadian => _value*1.3558179483314, + RotationalStiffnessUnit.PoundForceFootPerDegrees => _value*77.6826, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(RotationalStiffnessUnit unit) @@ -530,44 +529,43 @@ private double GetValueAs(RotationalStiffnessUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case RotationalStiffnessUnit.CentinewtonMeterPerDegree: return (baseUnitValue/(180/3.1415926535897931)) / 1e-2d; - case RotationalStiffnessUnit.CentinewtonMillimeterPerDegree: return (baseUnitValue/180*3.1415926535897931*1000) / 1e-2d; - case RotationalStiffnessUnit.CentinewtonMillimeterPerRadian: return (baseUnitValue*1000) / 1e-2d; - case RotationalStiffnessUnit.DecanewtonMeterPerDegree: return (baseUnitValue/(180/3.1415926535897931)) / 1e1d; - case RotationalStiffnessUnit.DecanewtonMillimeterPerDegree: return (baseUnitValue/180*3.1415926535897931*1000) / 1e1d; - case RotationalStiffnessUnit.DecanewtonMillimeterPerRadian: return (baseUnitValue*1000) / 1e1d; - case RotationalStiffnessUnit.DecinewtonMeterPerDegree: return (baseUnitValue/(180/3.1415926535897931)) / 1e-1d; - case RotationalStiffnessUnit.DecinewtonMillimeterPerDegree: return (baseUnitValue/180*3.1415926535897931*1000) / 1e-1d; - case RotationalStiffnessUnit.DecinewtonMillimeterPerRadian: return (baseUnitValue*1000) / 1e-1d; - case RotationalStiffnessUnit.KilonewtonMeterPerDegree: return (baseUnitValue/(180/3.1415926535897931)) / 1e3d; - case RotationalStiffnessUnit.KilonewtonMeterPerRadian: return (baseUnitValue) / 1e3d; - case RotationalStiffnessUnit.KilonewtonMillimeterPerDegree: return (baseUnitValue/180*3.1415926535897931*1000) / 1e3d; - case RotationalStiffnessUnit.KilonewtonMillimeterPerRadian: return (baseUnitValue*1000) / 1e3d; - case RotationalStiffnessUnit.KilopoundForceFootPerDegrees: return baseUnitValue/77682.6; - case RotationalStiffnessUnit.MeganewtonMeterPerDegree: return (baseUnitValue/(180/3.1415926535897931)) / 1e6d; - case RotationalStiffnessUnit.MeganewtonMeterPerRadian: return (baseUnitValue) / 1e6d; - case RotationalStiffnessUnit.MeganewtonMillimeterPerDegree: return (baseUnitValue/180*3.1415926535897931*1000) / 1e6d; - case RotationalStiffnessUnit.MeganewtonMillimeterPerRadian: return (baseUnitValue*1000) / 1e6d; - case RotationalStiffnessUnit.MicronewtonMeterPerDegree: return (baseUnitValue/(180/3.1415926535897931)) / 1e-6d; - case RotationalStiffnessUnit.MicronewtonMillimeterPerDegree: return (baseUnitValue/180*3.1415926535897931*1000) / 1e-6d; - case RotationalStiffnessUnit.MicronewtonMillimeterPerRadian: return (baseUnitValue*1000) / 1e-6d; - case RotationalStiffnessUnit.MillinewtonMeterPerDegree: return (baseUnitValue/(180/3.1415926535897931)) / 1e-3d; - case RotationalStiffnessUnit.MillinewtonMillimeterPerDegree: return (baseUnitValue/180*3.1415926535897931*1000) / 1e-3d; - case RotationalStiffnessUnit.MillinewtonMillimeterPerRadian: return (baseUnitValue*1000) / 1e-3d; - case RotationalStiffnessUnit.NanonewtonMeterPerDegree: return (baseUnitValue/(180/3.1415926535897931)) / 1e-9d; - case RotationalStiffnessUnit.NanonewtonMillimeterPerDegree: return (baseUnitValue/180*3.1415926535897931*1000) / 1e-9d; - case RotationalStiffnessUnit.NanonewtonMillimeterPerRadian: return (baseUnitValue*1000) / 1e-9d; - case RotationalStiffnessUnit.NewtonMeterPerDegree: return baseUnitValue/(180/3.1415926535897931); - case RotationalStiffnessUnit.NewtonMeterPerRadian: return baseUnitValue; - case RotationalStiffnessUnit.NewtonMillimeterPerDegree: return baseUnitValue/180*3.1415926535897931*1000; - case RotationalStiffnessUnit.NewtonMillimeterPerRadian: return baseUnitValue*1000; - case RotationalStiffnessUnit.PoundForceFeetPerRadian: return baseUnitValue/1.3558179483314; - case RotationalStiffnessUnit.PoundForceFootPerDegrees: return baseUnitValue/77.6826; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + RotationalStiffnessUnit.CentinewtonMeterPerDegree => (baseUnitValue/(180/3.1415926535897931)) / 1e-2d, + RotationalStiffnessUnit.CentinewtonMillimeterPerDegree => (baseUnitValue/180*3.1415926535897931*1000) / 1e-2d, + RotationalStiffnessUnit.CentinewtonMillimeterPerRadian => (baseUnitValue*1000) / 1e-2d, + RotationalStiffnessUnit.DecanewtonMeterPerDegree => (baseUnitValue/(180/3.1415926535897931)) / 1e1d, + RotationalStiffnessUnit.DecanewtonMillimeterPerDegree => (baseUnitValue/180*3.1415926535897931*1000) / 1e1d, + RotationalStiffnessUnit.DecanewtonMillimeterPerRadian => (baseUnitValue*1000) / 1e1d, + RotationalStiffnessUnit.DecinewtonMeterPerDegree => (baseUnitValue/(180/3.1415926535897931)) / 1e-1d, + RotationalStiffnessUnit.DecinewtonMillimeterPerDegree => (baseUnitValue/180*3.1415926535897931*1000) / 1e-1d, + RotationalStiffnessUnit.DecinewtonMillimeterPerRadian => (baseUnitValue*1000) / 1e-1d, + RotationalStiffnessUnit.KilonewtonMeterPerDegree => (baseUnitValue/(180/3.1415926535897931)) / 1e3d, + RotationalStiffnessUnit.KilonewtonMeterPerRadian => (baseUnitValue) / 1e3d, + RotationalStiffnessUnit.KilonewtonMillimeterPerDegree => (baseUnitValue/180*3.1415926535897931*1000) / 1e3d, + RotationalStiffnessUnit.KilonewtonMillimeterPerRadian => (baseUnitValue*1000) / 1e3d, + RotationalStiffnessUnit.KilopoundForceFootPerDegrees => baseUnitValue/77682.6, + RotationalStiffnessUnit.MeganewtonMeterPerDegree => (baseUnitValue/(180/3.1415926535897931)) / 1e6d, + RotationalStiffnessUnit.MeganewtonMeterPerRadian => (baseUnitValue) / 1e6d, + RotationalStiffnessUnit.MeganewtonMillimeterPerDegree => (baseUnitValue/180*3.1415926535897931*1000) / 1e6d, + RotationalStiffnessUnit.MeganewtonMillimeterPerRadian => (baseUnitValue*1000) / 1e6d, + RotationalStiffnessUnit.MicronewtonMeterPerDegree => (baseUnitValue/(180/3.1415926535897931)) / 1e-6d, + RotationalStiffnessUnit.MicronewtonMillimeterPerDegree => (baseUnitValue/180*3.1415926535897931*1000) / 1e-6d, + RotationalStiffnessUnit.MicronewtonMillimeterPerRadian => (baseUnitValue*1000) / 1e-6d, + RotationalStiffnessUnit.MillinewtonMeterPerDegree => (baseUnitValue/(180/3.1415926535897931)) / 1e-3d, + RotationalStiffnessUnit.MillinewtonMillimeterPerDegree => (baseUnitValue/180*3.1415926535897931*1000) / 1e-3d, + RotationalStiffnessUnit.MillinewtonMillimeterPerRadian => (baseUnitValue*1000) / 1e-3d, + RotationalStiffnessUnit.NanonewtonMeterPerDegree => (baseUnitValue/(180/3.1415926535897931)) / 1e-9d, + RotationalStiffnessUnit.NanonewtonMillimeterPerDegree => (baseUnitValue/180*3.1415926535897931*1000) / 1e-9d, + RotationalStiffnessUnit.NanonewtonMillimeterPerRadian => (baseUnitValue*1000) / 1e-9d, + RotationalStiffnessUnit.NewtonMeterPerDegree => baseUnitValue/(180/3.1415926535897931), + RotationalStiffnessUnit.NewtonMeterPerRadian => baseUnitValue, + RotationalStiffnessUnit.NewtonMillimeterPerDegree => baseUnitValue/180*3.1415926535897931*1000, + RotationalStiffnessUnit.NewtonMillimeterPerRadian => baseUnitValue*1000, + RotationalStiffnessUnit.PoundForceFeetPerRadian => baseUnitValue/1.3558179483314, + RotationalStiffnessUnit.PoundForceFootPerDegrees => baseUnitValue/77.6826, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 1da7148e0e..5a197a2abf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -175,16 +175,15 @@ public RotationalStiffnessPerLength ToUnit(RotationalStiffnessPerLengthUnit unit /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter: return (_value) * 1e3d; - case RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot: return _value*254864.324570; - case RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter: return (_value) * 1e6d; - case RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter: return _value; - case RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot: return _value*254.864324570; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter => (_value) * 1e3d, + RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot => _value*254864.324570, + RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter => (_value) * 1e6d, + RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter => _value, + RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot => _value*254.864324570, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(RotationalStiffnessPerLengthUnit unit) @@ -194,16 +193,15 @@ private double GetValueAs(RotationalStiffnessPerLengthUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter: return (baseUnitValue) / 1e3d; - case RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot: return baseUnitValue/254864.324570; - case RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter: return (baseUnitValue) / 1e6d; - case RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter: return baseUnitValue; - case RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot: return baseUnitValue/254.864324570; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter => (baseUnitValue) / 1e3d, + RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot => baseUnitValue/254864.324570, + RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter => (baseUnitValue) / 1e6d, + RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter => baseUnitValue, + RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot => baseUnitValue/254.864324570, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Scalar.g.cs index 2ab93c4962..fd6b015008 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Scalar.g.cs @@ -131,12 +131,11 @@ public Scalar ToUnit(ScalarUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ScalarUnit.Amount: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ScalarUnit.Amount => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ScalarUnit unit) @@ -146,12 +145,11 @@ private double GetValueAs(ScalarUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ScalarUnit.Amount: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ScalarUnit.Amount => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SolidAngle.g.cs index 55658df3d2..448ad4dc93 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SolidAngle.g.cs @@ -134,12 +134,11 @@ public SolidAngle ToUnit(SolidAngleUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case SolidAngleUnit.Steradian: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + SolidAngleUnit.Steradian => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(SolidAngleUnit unit) @@ -149,12 +148,11 @@ private double GetValueAs(SolidAngleUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case SolidAngleUnit.Steradian: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + SolidAngleUnit.Steradian => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEnergy.g.cs index b6c763400d..0ac54a2d49 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -398,36 +398,35 @@ public SpecificEnergy ToUnit(SpecificEnergyUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case SpecificEnergyUnit.BtuPerPound: return _value*2326.000075362; - case SpecificEnergyUnit.CaloriePerGram: return _value*4.184e3; - case SpecificEnergyUnit.GigawattDayPerKilogram: return (_value*(24*3.6e3)) * 1e9d; - case SpecificEnergyUnit.GigawattDayPerShortTon: return (_value*((24*3.6e3)/9.0718474e2)) * 1e9d; - case SpecificEnergyUnit.GigawattDayPerTonne: return (_value*((24*3.6e3)/1e3)) * 1e9d; - case SpecificEnergyUnit.GigawattHourPerKilogram: return (_value*3.6e3) * 1e9d; - case SpecificEnergyUnit.JoulePerKilogram: return _value; - case SpecificEnergyUnit.KilocaloriePerGram: return (_value*4.184e3) * 1e3d; - case SpecificEnergyUnit.KilojoulePerKilogram: return (_value) * 1e3d; - case SpecificEnergyUnit.KilowattDayPerKilogram: return (_value*(24*3.6e3)) * 1e3d; - case SpecificEnergyUnit.KilowattDayPerShortTon: return (_value*((24*3.6e3)/9.0718474e2)) * 1e3d; - case SpecificEnergyUnit.KilowattDayPerTonne: return (_value*((24*3.6e3)/1e3)) * 1e3d; - case SpecificEnergyUnit.KilowattHourPerKilogram: return (_value*3.6e3) * 1e3d; - case SpecificEnergyUnit.MegajoulePerKilogram: return (_value) * 1e6d; - case SpecificEnergyUnit.MegawattDayPerKilogram: return (_value*(24*3.6e3)) * 1e6d; - case SpecificEnergyUnit.MegawattDayPerShortTon: return (_value*((24*3.6e3)/9.0718474e2)) * 1e6d; - case SpecificEnergyUnit.MegawattDayPerTonne: return (_value*((24*3.6e3)/1e3)) * 1e6d; - case SpecificEnergyUnit.MegawattHourPerKilogram: return (_value*3.6e3) * 1e6d; - case SpecificEnergyUnit.TerawattDayPerKilogram: return (_value*(24*3.6e3)) * 1e12d; - case SpecificEnergyUnit.TerawattDayPerShortTon: return (_value*((24*3.6e3)/9.0718474e2)) * 1e12d; - case SpecificEnergyUnit.TerawattDayPerTonne: return (_value*((24*3.6e3)/1e3)) * 1e12d; - case SpecificEnergyUnit.WattDayPerKilogram: return _value*(24*3.6e3); - case SpecificEnergyUnit.WattDayPerShortTon: return _value*((24*3.6e3)/9.0718474e2); - case SpecificEnergyUnit.WattDayPerTonne: return _value*((24*3.6e3)/1e3); - case SpecificEnergyUnit.WattHourPerKilogram: return _value*3.6e3; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + SpecificEnergyUnit.BtuPerPound => _value*2326.000075362, + SpecificEnergyUnit.CaloriePerGram => _value*4.184e3, + SpecificEnergyUnit.GigawattDayPerKilogram => (_value*(24*3.6e3)) * 1e9d, + SpecificEnergyUnit.GigawattDayPerShortTon => (_value*((24*3.6e3)/9.0718474e2)) * 1e9d, + SpecificEnergyUnit.GigawattDayPerTonne => (_value*((24*3.6e3)/1e3)) * 1e9d, + SpecificEnergyUnit.GigawattHourPerKilogram => (_value*3.6e3) * 1e9d, + SpecificEnergyUnit.JoulePerKilogram => _value, + SpecificEnergyUnit.KilocaloriePerGram => (_value*4.184e3) * 1e3d, + SpecificEnergyUnit.KilojoulePerKilogram => (_value) * 1e3d, + SpecificEnergyUnit.KilowattDayPerKilogram => (_value*(24*3.6e3)) * 1e3d, + SpecificEnergyUnit.KilowattDayPerShortTon => (_value*((24*3.6e3)/9.0718474e2)) * 1e3d, + SpecificEnergyUnit.KilowattDayPerTonne => (_value*((24*3.6e3)/1e3)) * 1e3d, + SpecificEnergyUnit.KilowattHourPerKilogram => (_value*3.6e3) * 1e3d, + SpecificEnergyUnit.MegajoulePerKilogram => (_value) * 1e6d, + SpecificEnergyUnit.MegawattDayPerKilogram => (_value*(24*3.6e3)) * 1e6d, + SpecificEnergyUnit.MegawattDayPerShortTon => (_value*((24*3.6e3)/9.0718474e2)) * 1e6d, + SpecificEnergyUnit.MegawattDayPerTonne => (_value*((24*3.6e3)/1e3)) * 1e6d, + SpecificEnergyUnit.MegawattHourPerKilogram => (_value*3.6e3) * 1e6d, + SpecificEnergyUnit.TerawattDayPerKilogram => (_value*(24*3.6e3)) * 1e12d, + SpecificEnergyUnit.TerawattDayPerShortTon => (_value*((24*3.6e3)/9.0718474e2)) * 1e12d, + SpecificEnergyUnit.TerawattDayPerTonne => (_value*((24*3.6e3)/1e3)) * 1e12d, + SpecificEnergyUnit.WattDayPerKilogram => _value*(24*3.6e3), + SpecificEnergyUnit.WattDayPerShortTon => _value*((24*3.6e3)/9.0718474e2), + SpecificEnergyUnit.WattDayPerTonne => _value*((24*3.6e3)/1e3), + SpecificEnergyUnit.WattHourPerKilogram => _value*3.6e3, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(SpecificEnergyUnit unit) @@ -437,36 +436,35 @@ private double GetValueAs(SpecificEnergyUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case SpecificEnergyUnit.BtuPerPound: return baseUnitValue/2326.000075362; - case SpecificEnergyUnit.CaloriePerGram: return baseUnitValue/4.184e3; - case SpecificEnergyUnit.GigawattDayPerKilogram: return (baseUnitValue/(24*3.6e3)) / 1e9d; - case SpecificEnergyUnit.GigawattDayPerShortTon: return (baseUnitValue/((24*3.6e3)/9.0718474e2)) / 1e9d; - case SpecificEnergyUnit.GigawattDayPerTonne: return (baseUnitValue/((24*3.6e3)/1e3)) / 1e9d; - case SpecificEnergyUnit.GigawattHourPerKilogram: return (baseUnitValue/3.6e3) / 1e9d; - case SpecificEnergyUnit.JoulePerKilogram: return baseUnitValue; - case SpecificEnergyUnit.KilocaloriePerGram: return (baseUnitValue/4.184e3) / 1e3d; - case SpecificEnergyUnit.KilojoulePerKilogram: return (baseUnitValue) / 1e3d; - case SpecificEnergyUnit.KilowattDayPerKilogram: return (baseUnitValue/(24*3.6e3)) / 1e3d; - case SpecificEnergyUnit.KilowattDayPerShortTon: return (baseUnitValue/((24*3.6e3)/9.0718474e2)) / 1e3d; - case SpecificEnergyUnit.KilowattDayPerTonne: return (baseUnitValue/((24*3.6e3)/1e3)) / 1e3d; - case SpecificEnergyUnit.KilowattHourPerKilogram: return (baseUnitValue/3.6e3) / 1e3d; - case SpecificEnergyUnit.MegajoulePerKilogram: return (baseUnitValue) / 1e6d; - case SpecificEnergyUnit.MegawattDayPerKilogram: return (baseUnitValue/(24*3.6e3)) / 1e6d; - case SpecificEnergyUnit.MegawattDayPerShortTon: return (baseUnitValue/((24*3.6e3)/9.0718474e2)) / 1e6d; - case SpecificEnergyUnit.MegawattDayPerTonne: return (baseUnitValue/((24*3.6e3)/1e3)) / 1e6d; - case SpecificEnergyUnit.MegawattHourPerKilogram: return (baseUnitValue/3.6e3) / 1e6d; - case SpecificEnergyUnit.TerawattDayPerKilogram: return (baseUnitValue/(24*3.6e3)) / 1e12d; - case SpecificEnergyUnit.TerawattDayPerShortTon: return (baseUnitValue/((24*3.6e3)/9.0718474e2)) / 1e12d; - case SpecificEnergyUnit.TerawattDayPerTonne: return (baseUnitValue/((24*3.6e3)/1e3)) / 1e12d; - case SpecificEnergyUnit.WattDayPerKilogram: return baseUnitValue/(24*3.6e3); - case SpecificEnergyUnit.WattDayPerShortTon: return baseUnitValue/((24*3.6e3)/9.0718474e2); - case SpecificEnergyUnit.WattDayPerTonne: return baseUnitValue/((24*3.6e3)/1e3); - case SpecificEnergyUnit.WattHourPerKilogram: return baseUnitValue/3.6e3; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + SpecificEnergyUnit.BtuPerPound => baseUnitValue/2326.000075362, + SpecificEnergyUnit.CaloriePerGram => baseUnitValue/4.184e3, + SpecificEnergyUnit.GigawattDayPerKilogram => (baseUnitValue/(24*3.6e3)) / 1e9d, + SpecificEnergyUnit.GigawattDayPerShortTon => (baseUnitValue/((24*3.6e3)/9.0718474e2)) / 1e9d, + SpecificEnergyUnit.GigawattDayPerTonne => (baseUnitValue/((24*3.6e3)/1e3)) / 1e9d, + SpecificEnergyUnit.GigawattHourPerKilogram => (baseUnitValue/3.6e3) / 1e9d, + SpecificEnergyUnit.JoulePerKilogram => baseUnitValue, + SpecificEnergyUnit.KilocaloriePerGram => (baseUnitValue/4.184e3) / 1e3d, + SpecificEnergyUnit.KilojoulePerKilogram => (baseUnitValue) / 1e3d, + SpecificEnergyUnit.KilowattDayPerKilogram => (baseUnitValue/(24*3.6e3)) / 1e3d, + SpecificEnergyUnit.KilowattDayPerShortTon => (baseUnitValue/((24*3.6e3)/9.0718474e2)) / 1e3d, + SpecificEnergyUnit.KilowattDayPerTonne => (baseUnitValue/((24*3.6e3)/1e3)) / 1e3d, + SpecificEnergyUnit.KilowattHourPerKilogram => (baseUnitValue/3.6e3) / 1e3d, + SpecificEnergyUnit.MegajoulePerKilogram => (baseUnitValue) / 1e6d, + SpecificEnergyUnit.MegawattDayPerKilogram => (baseUnitValue/(24*3.6e3)) / 1e6d, + SpecificEnergyUnit.MegawattDayPerShortTon => (baseUnitValue/((24*3.6e3)/9.0718474e2)) / 1e6d, + SpecificEnergyUnit.MegawattDayPerTonne => (baseUnitValue/((24*3.6e3)/1e3)) / 1e6d, + SpecificEnergyUnit.MegawattHourPerKilogram => (baseUnitValue/3.6e3) / 1e6d, + SpecificEnergyUnit.TerawattDayPerKilogram => (baseUnitValue/(24*3.6e3)) / 1e12d, + SpecificEnergyUnit.TerawattDayPerShortTon => (baseUnitValue/((24*3.6e3)/9.0718474e2)) / 1e12d, + SpecificEnergyUnit.TerawattDayPerTonne => (baseUnitValue/((24*3.6e3)/1e3)) / 1e12d, + SpecificEnergyUnit.WattDayPerKilogram => baseUnitValue/(24*3.6e3), + SpecificEnergyUnit.WattDayPerShortTon => baseUnitValue/((24*3.6e3)/9.0718474e2), + SpecificEnergyUnit.WattDayPerTonne => baseUnitValue/((24*3.6e3)/1e3), + SpecificEnergyUnit.WattHourPerKilogram => baseUnitValue/3.6e3, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEntropy.g.cs index 5f149aa9ee..707a897260 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -219,20 +219,19 @@ public SpecificEntropy ToUnit(SpecificEntropyUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case SpecificEntropyUnit.BtuPerPoundFahrenheit: return _value * 4.1868e3; - case SpecificEntropyUnit.CaloriePerGramKelvin: return _value*4.184e3; - case SpecificEntropyUnit.JoulePerKilogramDegreeCelsius: return _value; - case SpecificEntropyUnit.JoulePerKilogramKelvin: return _value; - case SpecificEntropyUnit.KilocaloriePerGramKelvin: return (_value*4.184e3) * 1e3d; - case SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius: return (_value) * 1e3d; - case SpecificEntropyUnit.KilojoulePerKilogramKelvin: return (_value) * 1e3d; - case SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius: return (_value) * 1e6d; - case SpecificEntropyUnit.MegajoulePerKilogramKelvin: return (_value) * 1e6d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + SpecificEntropyUnit.BtuPerPoundFahrenheit => _value * 4.1868e3, + SpecificEntropyUnit.CaloriePerGramKelvin => _value*4.184e3, + SpecificEntropyUnit.JoulePerKilogramDegreeCelsius => _value, + SpecificEntropyUnit.JoulePerKilogramKelvin => _value, + SpecificEntropyUnit.KilocaloriePerGramKelvin => (_value*4.184e3) * 1e3d, + SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius => (_value) * 1e3d, + SpecificEntropyUnit.KilojoulePerKilogramKelvin => (_value) * 1e3d, + SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius => (_value) * 1e6d, + SpecificEntropyUnit.MegajoulePerKilogramKelvin => (_value) * 1e6d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(SpecificEntropyUnit unit) @@ -242,20 +241,19 @@ private double GetValueAs(SpecificEntropyUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case SpecificEntropyUnit.BtuPerPoundFahrenheit: return baseUnitValue / 4.1868e3; - case SpecificEntropyUnit.CaloriePerGramKelvin: return baseUnitValue/4.184e3; - case SpecificEntropyUnit.JoulePerKilogramDegreeCelsius: return baseUnitValue; - case SpecificEntropyUnit.JoulePerKilogramKelvin: return baseUnitValue; - case SpecificEntropyUnit.KilocaloriePerGramKelvin: return (baseUnitValue/4.184e3) / 1e3d; - case SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius: return (baseUnitValue) / 1e3d; - case SpecificEntropyUnit.KilojoulePerKilogramKelvin: return (baseUnitValue) / 1e3d; - case SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius: return (baseUnitValue) / 1e6d; - case SpecificEntropyUnit.MegajoulePerKilogramKelvin: return (baseUnitValue) / 1e6d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + SpecificEntropyUnit.BtuPerPoundFahrenheit => baseUnitValue / 4.1868e3, + SpecificEntropyUnit.CaloriePerGramKelvin => baseUnitValue/4.184e3, + SpecificEntropyUnit.JoulePerKilogramDegreeCelsius => baseUnitValue, + SpecificEntropyUnit.JoulePerKilogramKelvin => baseUnitValue, + SpecificEntropyUnit.KilocaloriePerGramKelvin => (baseUnitValue/4.184e3) / 1e3d, + SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius => (baseUnitValue) / 1e3d, + SpecificEntropyUnit.KilojoulePerKilogramKelvin => (baseUnitValue) / 1e3d, + SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius => (baseUnitValue) / 1e6d, + SpecificEntropyUnit.MegajoulePerKilogramKelvin => (baseUnitValue) / 1e6d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 1abee426d5..877e41182d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -167,15 +167,14 @@ public SpecificFuelConsumption ToUnit(SpecificFuelConsumptionUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond: return _value; - case SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour: return _value*28.33; - case SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond: return (_value) * 1e3d; - case SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour: return _value*28.33; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond => _value, + SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour => _value*28.33, + SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond => (_value) * 1e3d, + SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour => _value*28.33, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(SpecificFuelConsumptionUnit unit) @@ -185,15 +184,14 @@ private double GetValueAs(SpecificFuelConsumptionUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond: return baseUnitValue; - case SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour: return baseUnitValue/28.33; - case SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond: return (baseUnitValue) / 1e3d; - case SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour: return baseUnitValue/28.33; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond => baseUnitValue, + SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour => baseUnitValue/28.33, + SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond => (baseUnitValue) / 1e3d, + SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour => baseUnitValue/28.33, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificVolume.g.cs index 8a8496ecb1..c7e482c68d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -153,14 +153,13 @@ public SpecificVolume ToUnit(SpecificVolumeUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case SpecificVolumeUnit.CubicFootPerPound: return _value/16.01846353; - case SpecificVolumeUnit.CubicMeterPerKilogram: return _value; - case SpecificVolumeUnit.MillicubicMeterPerKilogram: return (_value) * 1e-3d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + SpecificVolumeUnit.CubicFootPerPound => _value/16.01846353, + SpecificVolumeUnit.CubicMeterPerKilogram => _value, + SpecificVolumeUnit.MillicubicMeterPerKilogram => (_value) * 1e-3d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(SpecificVolumeUnit unit) @@ -170,14 +169,13 @@ private double GetValueAs(SpecificVolumeUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case SpecificVolumeUnit.CubicFootPerPound: return baseUnitValue*16.01846353; - case SpecificVolumeUnit.CubicMeterPerKilogram: return baseUnitValue; - case SpecificVolumeUnit.MillicubicMeterPerKilogram: return (baseUnitValue) / 1e-3d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + SpecificVolumeUnit.CubicFootPerPound => baseUnitValue*16.01846353, + SpecificVolumeUnit.CubicMeterPerKilogram => baseUnitValue, + SpecificVolumeUnit.MillicubicMeterPerKilogram => (baseUnitValue) / 1e-3d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificWeight.g.cs index 576b23526a..f35f63e9c2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -310,28 +310,27 @@ public SpecificWeight ToUnit(SpecificWeightUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case SpecificWeightUnit.KilogramForcePerCubicCentimeter: return _value*9.80665e6; - case SpecificWeightUnit.KilogramForcePerCubicMeter: return _value*9.80665; - case SpecificWeightUnit.KilogramForcePerCubicMillimeter: return _value*9.80665e9; - case SpecificWeightUnit.KilonewtonPerCubicCentimeter: return (_value*1000000) * 1e3d; - case SpecificWeightUnit.KilonewtonPerCubicMeter: return (_value) * 1e3d; - case SpecificWeightUnit.KilonewtonPerCubicMillimeter: return (_value*1000000000) * 1e3d; - case SpecificWeightUnit.KilopoundForcePerCubicFoot: return (_value*1.570874638462462e2) * 1e3d; - case SpecificWeightUnit.KilopoundForcePerCubicInch: return (_value*2.714471375263134e5) * 1e3d; - case SpecificWeightUnit.MeganewtonPerCubicMeter: return (_value) * 1e6d; - case SpecificWeightUnit.NewtonPerCubicCentimeter: return _value*1000000; - case SpecificWeightUnit.NewtonPerCubicMeter: return _value; - case SpecificWeightUnit.NewtonPerCubicMillimeter: return _value*1000000000; - case SpecificWeightUnit.PoundForcePerCubicFoot: return _value*1.570874638462462e2; - case SpecificWeightUnit.PoundForcePerCubicInch: return _value*2.714471375263134e5; - case SpecificWeightUnit.TonneForcePerCubicCentimeter: return _value*9.80665e9; - case SpecificWeightUnit.TonneForcePerCubicMeter: return _value*9.80665e3; - case SpecificWeightUnit.TonneForcePerCubicMillimeter: return _value*9.80665e12; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + SpecificWeightUnit.KilogramForcePerCubicCentimeter => _value*9.80665e6, + SpecificWeightUnit.KilogramForcePerCubicMeter => _value*9.80665, + SpecificWeightUnit.KilogramForcePerCubicMillimeter => _value*9.80665e9, + SpecificWeightUnit.KilonewtonPerCubicCentimeter => (_value*1000000) * 1e3d, + SpecificWeightUnit.KilonewtonPerCubicMeter => (_value) * 1e3d, + SpecificWeightUnit.KilonewtonPerCubicMillimeter => (_value*1000000000) * 1e3d, + SpecificWeightUnit.KilopoundForcePerCubicFoot => (_value*1.570874638462462e2) * 1e3d, + SpecificWeightUnit.KilopoundForcePerCubicInch => (_value*2.714471375263134e5) * 1e3d, + SpecificWeightUnit.MeganewtonPerCubicMeter => (_value) * 1e6d, + SpecificWeightUnit.NewtonPerCubicCentimeter => _value*1000000, + SpecificWeightUnit.NewtonPerCubicMeter => _value, + SpecificWeightUnit.NewtonPerCubicMillimeter => _value*1000000000, + SpecificWeightUnit.PoundForcePerCubicFoot => _value*1.570874638462462e2, + SpecificWeightUnit.PoundForcePerCubicInch => _value*2.714471375263134e5, + SpecificWeightUnit.TonneForcePerCubicCentimeter => _value*9.80665e9, + SpecificWeightUnit.TonneForcePerCubicMeter => _value*9.80665e3, + SpecificWeightUnit.TonneForcePerCubicMillimeter => _value*9.80665e12, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(SpecificWeightUnit unit) @@ -341,28 +340,27 @@ private double GetValueAs(SpecificWeightUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case SpecificWeightUnit.KilogramForcePerCubicCentimeter: return baseUnitValue/9.80665e6; - case SpecificWeightUnit.KilogramForcePerCubicMeter: return baseUnitValue/9.80665; - case SpecificWeightUnit.KilogramForcePerCubicMillimeter: return baseUnitValue/9.80665e9; - case SpecificWeightUnit.KilonewtonPerCubicCentimeter: return (baseUnitValue*0.000001) / 1e3d; - case SpecificWeightUnit.KilonewtonPerCubicMeter: return (baseUnitValue) / 1e3d; - case SpecificWeightUnit.KilonewtonPerCubicMillimeter: return (baseUnitValue*0.000000001) / 1e3d; - case SpecificWeightUnit.KilopoundForcePerCubicFoot: return (baseUnitValue/1.570874638462462e2) / 1e3d; - case SpecificWeightUnit.KilopoundForcePerCubicInch: return (baseUnitValue/2.714471375263134e5) / 1e3d; - case SpecificWeightUnit.MeganewtonPerCubicMeter: return (baseUnitValue) / 1e6d; - case SpecificWeightUnit.NewtonPerCubicCentimeter: return baseUnitValue*0.000001; - case SpecificWeightUnit.NewtonPerCubicMeter: return baseUnitValue; - case SpecificWeightUnit.NewtonPerCubicMillimeter: return baseUnitValue*0.000000001; - case SpecificWeightUnit.PoundForcePerCubicFoot: return baseUnitValue/1.570874638462462e2; - case SpecificWeightUnit.PoundForcePerCubicInch: return baseUnitValue/2.714471375263134e5; - case SpecificWeightUnit.TonneForcePerCubicCentimeter: return baseUnitValue/9.80665e9; - case SpecificWeightUnit.TonneForcePerCubicMeter: return baseUnitValue/9.80665e3; - case SpecificWeightUnit.TonneForcePerCubicMillimeter: return baseUnitValue/9.80665e12; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + SpecificWeightUnit.KilogramForcePerCubicCentimeter => baseUnitValue/9.80665e6, + SpecificWeightUnit.KilogramForcePerCubicMeter => baseUnitValue/9.80665, + SpecificWeightUnit.KilogramForcePerCubicMillimeter => baseUnitValue/9.80665e9, + SpecificWeightUnit.KilonewtonPerCubicCentimeter => (baseUnitValue*0.000001) / 1e3d, + SpecificWeightUnit.KilonewtonPerCubicMeter => (baseUnitValue) / 1e3d, + SpecificWeightUnit.KilonewtonPerCubicMillimeter => (baseUnitValue*0.000000001) / 1e3d, + SpecificWeightUnit.KilopoundForcePerCubicFoot => (baseUnitValue/1.570874638462462e2) / 1e3d, + SpecificWeightUnit.KilopoundForcePerCubicInch => (baseUnitValue/2.714471375263134e5) / 1e3d, + SpecificWeightUnit.MeganewtonPerCubicMeter => (baseUnitValue) / 1e6d, + SpecificWeightUnit.NewtonPerCubicCentimeter => baseUnitValue*0.000001, + SpecificWeightUnit.NewtonPerCubicMeter => baseUnitValue, + SpecificWeightUnit.NewtonPerCubicMillimeter => baseUnitValue*0.000000001, + SpecificWeightUnit.PoundForcePerCubicFoot => baseUnitValue/1.570874638462462e2, + SpecificWeightUnit.PoundForcePerCubicInch => baseUnitValue/2.714471375263134e5, + SpecificWeightUnit.TonneForcePerCubicCentimeter => baseUnitValue/9.80665e9, + SpecificWeightUnit.TonneForcePerCubicMeter => baseUnitValue/9.80665e3, + SpecificWeightUnit.TonneForcePerCubicMillimeter => baseUnitValue/9.80665e12, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Speed.g.cs index f365e0aaec..3e54a87e53 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Speed.g.cs @@ -472,43 +472,42 @@ public Speed ToUnit(SpeedUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case SpeedUnit.CentimeterPerHour: return (_value/3600) * 1e-2d; - case SpeedUnit.CentimeterPerMinute: return (_value/60) * 1e-2d; - case SpeedUnit.CentimeterPerSecond: return (_value) * 1e-2d; - case SpeedUnit.DecimeterPerMinute: return (_value/60) * 1e-1d; - case SpeedUnit.DecimeterPerSecond: return (_value) * 1e-1d; - case SpeedUnit.FootPerHour: return _value*0.3048/3600; - case SpeedUnit.FootPerMinute: return _value*0.3048/60; - case SpeedUnit.FootPerSecond: return _value*0.3048; - case SpeedUnit.InchPerHour: return (_value/3600)*2.54e-2; - case SpeedUnit.InchPerMinute: return (_value/60)*2.54e-2; - case SpeedUnit.InchPerSecond: return _value*2.54e-2; - case SpeedUnit.KilometerPerHour: return (_value/3600) * 1e3d; - case SpeedUnit.KilometerPerMinute: return (_value/60) * 1e3d; - case SpeedUnit.KilometerPerSecond: return (_value) * 1e3d; - case SpeedUnit.Knot: return _value*0.514444; - case SpeedUnit.MeterPerHour: return _value/3600; - case SpeedUnit.MeterPerMinute: return _value/60; - case SpeedUnit.MeterPerSecond: return _value; - case SpeedUnit.MicrometerPerMinute: return (_value/60) * 1e-6d; - case SpeedUnit.MicrometerPerSecond: return (_value) * 1e-6d; - case SpeedUnit.MilePerHour: return _value*0.44704; - case SpeedUnit.MillimeterPerHour: return (_value/3600) * 1e-3d; - case SpeedUnit.MillimeterPerMinute: return (_value/60) * 1e-3d; - case SpeedUnit.MillimeterPerSecond: return (_value) * 1e-3d; - case SpeedUnit.NanometerPerMinute: return (_value/60) * 1e-9d; - case SpeedUnit.NanometerPerSecond: return (_value) * 1e-9d; - case SpeedUnit.UsSurveyFootPerHour: return (_value*1200/3937)/3600; - case SpeedUnit.UsSurveyFootPerMinute: return (_value*1200/3937)/60; - case SpeedUnit.UsSurveyFootPerSecond: return _value*1200/3937; - case SpeedUnit.YardPerHour: return _value*0.9144/3600; - case SpeedUnit.YardPerMinute: return _value*0.9144/60; - case SpeedUnit.YardPerSecond: return _value*0.9144; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + SpeedUnit.CentimeterPerHour => (_value/3600) * 1e-2d, + SpeedUnit.CentimeterPerMinute => (_value/60) * 1e-2d, + SpeedUnit.CentimeterPerSecond => (_value) * 1e-2d, + SpeedUnit.DecimeterPerMinute => (_value/60) * 1e-1d, + SpeedUnit.DecimeterPerSecond => (_value) * 1e-1d, + SpeedUnit.FootPerHour => _value*0.3048/3600, + SpeedUnit.FootPerMinute => _value*0.3048/60, + SpeedUnit.FootPerSecond => _value*0.3048, + SpeedUnit.InchPerHour => (_value/3600)*2.54e-2, + SpeedUnit.InchPerMinute => (_value/60)*2.54e-2, + SpeedUnit.InchPerSecond => _value*2.54e-2, + SpeedUnit.KilometerPerHour => (_value/3600) * 1e3d, + SpeedUnit.KilometerPerMinute => (_value/60) * 1e3d, + SpeedUnit.KilometerPerSecond => (_value) * 1e3d, + SpeedUnit.Knot => _value*0.514444, + SpeedUnit.MeterPerHour => _value/3600, + SpeedUnit.MeterPerMinute => _value/60, + SpeedUnit.MeterPerSecond => _value, + SpeedUnit.MicrometerPerMinute => (_value/60) * 1e-6d, + SpeedUnit.MicrometerPerSecond => (_value) * 1e-6d, + SpeedUnit.MilePerHour => _value*0.44704, + SpeedUnit.MillimeterPerHour => (_value/3600) * 1e-3d, + SpeedUnit.MillimeterPerMinute => (_value/60) * 1e-3d, + SpeedUnit.MillimeterPerSecond => (_value) * 1e-3d, + SpeedUnit.NanometerPerMinute => (_value/60) * 1e-9d, + SpeedUnit.NanometerPerSecond => (_value) * 1e-9d, + SpeedUnit.UsSurveyFootPerHour => (_value*1200/3937)/3600, + SpeedUnit.UsSurveyFootPerMinute => (_value*1200/3937)/60, + SpeedUnit.UsSurveyFootPerSecond => _value*1200/3937, + SpeedUnit.YardPerHour => _value*0.9144/3600, + SpeedUnit.YardPerMinute => _value*0.9144/60, + SpeedUnit.YardPerSecond => _value*0.9144, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(SpeedUnit unit) @@ -518,43 +517,42 @@ private double GetValueAs(SpeedUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case SpeedUnit.CentimeterPerHour: return (baseUnitValue*3600) / 1e-2d; - case SpeedUnit.CentimeterPerMinute: return (baseUnitValue*60) / 1e-2d; - case SpeedUnit.CentimeterPerSecond: return (baseUnitValue) / 1e-2d; - case SpeedUnit.DecimeterPerMinute: return (baseUnitValue*60) / 1e-1d; - case SpeedUnit.DecimeterPerSecond: return (baseUnitValue) / 1e-1d; - case SpeedUnit.FootPerHour: return baseUnitValue/0.3048*3600; - case SpeedUnit.FootPerMinute: return baseUnitValue/0.3048*60; - case SpeedUnit.FootPerSecond: return baseUnitValue/0.3048; - case SpeedUnit.InchPerHour: return (baseUnitValue/2.54e-2)*3600; - case SpeedUnit.InchPerMinute: return (baseUnitValue/2.54e-2)*60; - case SpeedUnit.InchPerSecond: return baseUnitValue/2.54e-2; - case SpeedUnit.KilometerPerHour: return (baseUnitValue*3600) / 1e3d; - case SpeedUnit.KilometerPerMinute: return (baseUnitValue*60) / 1e3d; - case SpeedUnit.KilometerPerSecond: return (baseUnitValue) / 1e3d; - case SpeedUnit.Knot: return baseUnitValue/0.514444; - case SpeedUnit.MeterPerHour: return baseUnitValue*3600; - case SpeedUnit.MeterPerMinute: return baseUnitValue*60; - case SpeedUnit.MeterPerSecond: return baseUnitValue; - case SpeedUnit.MicrometerPerMinute: return (baseUnitValue*60) / 1e-6d; - case SpeedUnit.MicrometerPerSecond: return (baseUnitValue) / 1e-6d; - case SpeedUnit.MilePerHour: return baseUnitValue/0.44704; - case SpeedUnit.MillimeterPerHour: return (baseUnitValue*3600) / 1e-3d; - case SpeedUnit.MillimeterPerMinute: return (baseUnitValue*60) / 1e-3d; - case SpeedUnit.MillimeterPerSecond: return (baseUnitValue) / 1e-3d; - case SpeedUnit.NanometerPerMinute: return (baseUnitValue*60) / 1e-9d; - case SpeedUnit.NanometerPerSecond: return (baseUnitValue) / 1e-9d; - case SpeedUnit.UsSurveyFootPerHour: return (baseUnitValue*3937/1200)*3600; - case SpeedUnit.UsSurveyFootPerMinute: return (baseUnitValue*3937/1200)*60; - case SpeedUnit.UsSurveyFootPerSecond: return baseUnitValue*3937/1200; - case SpeedUnit.YardPerHour: return baseUnitValue/0.9144*3600; - case SpeedUnit.YardPerMinute: return baseUnitValue/0.9144*60; - case SpeedUnit.YardPerSecond: return baseUnitValue/0.9144; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + SpeedUnit.CentimeterPerHour => (baseUnitValue*3600) / 1e-2d, + SpeedUnit.CentimeterPerMinute => (baseUnitValue*60) / 1e-2d, + SpeedUnit.CentimeterPerSecond => (baseUnitValue) / 1e-2d, + SpeedUnit.DecimeterPerMinute => (baseUnitValue*60) / 1e-1d, + SpeedUnit.DecimeterPerSecond => (baseUnitValue) / 1e-1d, + SpeedUnit.FootPerHour => baseUnitValue/0.3048*3600, + SpeedUnit.FootPerMinute => baseUnitValue/0.3048*60, + SpeedUnit.FootPerSecond => baseUnitValue/0.3048, + SpeedUnit.InchPerHour => (baseUnitValue/2.54e-2)*3600, + SpeedUnit.InchPerMinute => (baseUnitValue/2.54e-2)*60, + SpeedUnit.InchPerSecond => baseUnitValue/2.54e-2, + SpeedUnit.KilometerPerHour => (baseUnitValue*3600) / 1e3d, + SpeedUnit.KilometerPerMinute => (baseUnitValue*60) / 1e3d, + SpeedUnit.KilometerPerSecond => (baseUnitValue) / 1e3d, + SpeedUnit.Knot => baseUnitValue/0.514444, + SpeedUnit.MeterPerHour => baseUnitValue*3600, + SpeedUnit.MeterPerMinute => baseUnitValue*60, + SpeedUnit.MeterPerSecond => baseUnitValue, + SpeedUnit.MicrometerPerMinute => (baseUnitValue*60) / 1e-6d, + SpeedUnit.MicrometerPerSecond => (baseUnitValue) / 1e-6d, + SpeedUnit.MilePerHour => baseUnitValue/0.44704, + SpeedUnit.MillimeterPerHour => (baseUnitValue*3600) / 1e-3d, + SpeedUnit.MillimeterPerMinute => (baseUnitValue*60) / 1e-3d, + SpeedUnit.MillimeterPerSecond => (baseUnitValue) / 1e-3d, + SpeedUnit.NanometerPerMinute => (baseUnitValue*60) / 1e-9d, + SpeedUnit.NanometerPerSecond => (baseUnitValue) / 1e-9d, + SpeedUnit.UsSurveyFootPerHour => (baseUnitValue*3937/1200)*3600, + SpeedUnit.UsSurveyFootPerMinute => (baseUnitValue*3937/1200)*60, + SpeedUnit.UsSurveyFootPerSecond => baseUnitValue*3937/1200, + SpeedUnit.YardPerHour => baseUnitValue/0.9144*3600, + SpeedUnit.YardPerMinute => baseUnitValue/0.9144*60, + SpeedUnit.YardPerSecond => baseUnitValue/0.9144, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 8ad341fccd..538b271c73 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -219,20 +219,19 @@ public StandardVolumeFlow ToUnit(StandardVolumeFlowUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute: return _value/6e7; - case StandardVolumeFlowUnit.StandardCubicFootPerHour: return _value*7.8657907199999087346816086183876e-6; - case StandardVolumeFlowUnit.StandardCubicFootPerMinute: return _value/2118.88000326; - case StandardVolumeFlowUnit.StandardCubicFootPerSecond: return _value/35.314666721; - case StandardVolumeFlowUnit.StandardCubicMeterPerDay: return _value/86400; - case StandardVolumeFlowUnit.StandardCubicMeterPerHour: return _value/3600; - case StandardVolumeFlowUnit.StandardCubicMeterPerMinute: return _value/60; - case StandardVolumeFlowUnit.StandardCubicMeterPerSecond: return _value; - case StandardVolumeFlowUnit.StandardLiterPerMinute: return _value/60000; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute => _value/6e7, + StandardVolumeFlowUnit.StandardCubicFootPerHour => _value*7.8657907199999087346816086183876e-6, + StandardVolumeFlowUnit.StandardCubicFootPerMinute => _value/2118.88000326, + StandardVolumeFlowUnit.StandardCubicFootPerSecond => _value/35.314666721, + StandardVolumeFlowUnit.StandardCubicMeterPerDay => _value/86400, + StandardVolumeFlowUnit.StandardCubicMeterPerHour => _value/3600, + StandardVolumeFlowUnit.StandardCubicMeterPerMinute => _value/60, + StandardVolumeFlowUnit.StandardCubicMeterPerSecond => _value, + StandardVolumeFlowUnit.StandardLiterPerMinute => _value/60000, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(StandardVolumeFlowUnit unit) @@ -242,20 +241,19 @@ private double GetValueAs(StandardVolumeFlowUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute: return baseUnitValue*6e7; - case StandardVolumeFlowUnit.StandardCubicFootPerHour: return baseUnitValue/7.8657907199999087346816086183876e-6; - case StandardVolumeFlowUnit.StandardCubicFootPerMinute: return baseUnitValue*2118.88000326; - case StandardVolumeFlowUnit.StandardCubicFootPerSecond: return baseUnitValue*35.314666721; - case StandardVolumeFlowUnit.StandardCubicMeterPerDay: return baseUnitValue*86400; - case StandardVolumeFlowUnit.StandardCubicMeterPerHour: return baseUnitValue*3600; - case StandardVolumeFlowUnit.StandardCubicMeterPerMinute: return baseUnitValue*60; - case StandardVolumeFlowUnit.StandardCubicMeterPerSecond: return baseUnitValue; - case StandardVolumeFlowUnit.StandardLiterPerMinute: return baseUnitValue*60000; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute => baseUnitValue*6e7, + StandardVolumeFlowUnit.StandardCubicFootPerHour => baseUnitValue/7.8657907199999087346816086183876e-6, + StandardVolumeFlowUnit.StandardCubicFootPerMinute => baseUnitValue*2118.88000326, + StandardVolumeFlowUnit.StandardCubicFootPerSecond => baseUnitValue*35.314666721, + StandardVolumeFlowUnit.StandardCubicMeterPerDay => baseUnitValue*86400, + StandardVolumeFlowUnit.StandardCubicMeterPerHour => baseUnitValue*3600, + StandardVolumeFlowUnit.StandardCubicMeterPerMinute => baseUnitValue*60, + StandardVolumeFlowUnit.StandardCubicMeterPerSecond => baseUnitValue, + StandardVolumeFlowUnit.StandardLiterPerMinute => baseUnitValue*60000, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Temperature.g.cs index 6965f7db81..499e012899 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Temperature.g.cs @@ -230,21 +230,20 @@ public Temperature ToUnit(TemperatureUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case TemperatureUnit.DegreeCelsius: return _value + 273.15; - case TemperatureUnit.DegreeDelisle: return _value*-2/3 + 373.15; - case TemperatureUnit.DegreeFahrenheit: return _value*5/9 + 459.67*5/9; - case TemperatureUnit.DegreeNewton: return _value*100/33 + 273.15; - case TemperatureUnit.DegreeRankine: return _value*5/9; - case TemperatureUnit.DegreeReaumur: return _value*5/4 + 273.15; - case TemperatureUnit.DegreeRoemer: return _value*40/21 + 273.15 - 7.5*40d/21; - case TemperatureUnit.Kelvin: return _value; - case TemperatureUnit.MillidegreeCelsius: return _value / 1000 + 273.15; - case TemperatureUnit.SolarTemperature: return _value * 5778; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + TemperatureUnit.DegreeCelsius => _value + 273.15, + TemperatureUnit.DegreeDelisle => _value*-2/3 + 373.15, + TemperatureUnit.DegreeFahrenheit => _value*5/9 + 459.67*5/9, + TemperatureUnit.DegreeNewton => _value*100/33 + 273.15, + TemperatureUnit.DegreeRankine => _value*5/9, + TemperatureUnit.DegreeReaumur => _value*5/4 + 273.15, + TemperatureUnit.DegreeRoemer => _value*40/21 + 273.15 - 7.5*40d/21, + TemperatureUnit.Kelvin => _value, + TemperatureUnit.MillidegreeCelsius => _value / 1000 + 273.15, + TemperatureUnit.SolarTemperature => _value * 5778, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(TemperatureUnit unit) @@ -254,21 +253,20 @@ private double GetValueAs(TemperatureUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case TemperatureUnit.DegreeCelsius: return baseUnitValue - 273.15; - case TemperatureUnit.DegreeDelisle: return (baseUnitValue - 373.15)*-3/2; - case TemperatureUnit.DegreeFahrenheit: return (baseUnitValue - 459.67*5/9)*9/5; - case TemperatureUnit.DegreeNewton: return (baseUnitValue - 273.15)*33/100; - case TemperatureUnit.DegreeRankine: return baseUnitValue*9/5; - case TemperatureUnit.DegreeReaumur: return (baseUnitValue - 273.15)*4/5; - case TemperatureUnit.DegreeRoemer: return (baseUnitValue - (273.15 - 7.5*40d/21))*21/40; - case TemperatureUnit.Kelvin: return baseUnitValue; - case TemperatureUnit.MillidegreeCelsius: return (baseUnitValue - 273.15) * 1000; - case TemperatureUnit.SolarTemperature: return baseUnitValue / 5778; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + TemperatureUnit.DegreeCelsius => baseUnitValue - 273.15, + TemperatureUnit.DegreeDelisle => (baseUnitValue - 373.15)*-3/2, + TemperatureUnit.DegreeFahrenheit => (baseUnitValue - 459.67*5/9)*9/5, + TemperatureUnit.DegreeNewton => (baseUnitValue - 273.15)*33/100, + TemperatureUnit.DegreeRankine => baseUnitValue*9/5, + TemperatureUnit.DegreeReaumur => (baseUnitValue - 273.15)*4/5, + TemperatureUnit.DegreeRoemer => (baseUnitValue - (273.15 - 7.5*40d/21))*21/40, + TemperatureUnit.Kelvin => baseUnitValue, + TemperatureUnit.MillidegreeCelsius => (baseUnitValue - 273.15) * 1000, + TemperatureUnit.SolarTemperature => baseUnitValue / 5778, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 6408479051..e09599e0eb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -230,21 +230,20 @@ public TemperatureChangeRate ToUnit(TemperatureChangeRateUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond: return (_value) * 1e-2d; - case TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond: return (_value) * 1e1d; - case TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond: return (_value) * 1e-1d; - case TemperatureChangeRateUnit.DegreeCelsiusPerMinute: return _value/60; - case TemperatureChangeRateUnit.DegreeCelsiusPerSecond: return _value; - case TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond: return (_value) * 1e2d; - case TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond: return (_value) * 1e3d; - case TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond: return (_value) * 1e-6d; - case TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond: return (_value) * 1e-3d; - case TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond: return (_value) * 1e-9d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond => (_value) * 1e-2d, + TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond => (_value) * 1e1d, + TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond => (_value) * 1e-1d, + TemperatureChangeRateUnit.DegreeCelsiusPerMinute => _value/60, + TemperatureChangeRateUnit.DegreeCelsiusPerSecond => _value, + TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond => (_value) * 1e2d, + TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond => (_value) * 1e3d, + TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond => (_value) * 1e-6d, + TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond => (_value) * 1e-3d, + TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond => (_value) * 1e-9d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(TemperatureChangeRateUnit unit) @@ -254,21 +253,20 @@ private double GetValueAs(TemperatureChangeRateUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond: return (baseUnitValue) / 1e-2d; - case TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond: return (baseUnitValue) / 1e1d; - case TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond: return (baseUnitValue) / 1e-1d; - case TemperatureChangeRateUnit.DegreeCelsiusPerMinute: return baseUnitValue*60; - case TemperatureChangeRateUnit.DegreeCelsiusPerSecond: return baseUnitValue; - case TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond: return (baseUnitValue) / 1e2d; - case TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond: return (baseUnitValue) / 1e3d; - case TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond: return (baseUnitValue) / 1e-6d; - case TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond: return (baseUnitValue) / 1e-3d; - case TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond: return (baseUnitValue) / 1e-9d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond => (baseUnitValue) / 1e-2d, + TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond => (baseUnitValue) / 1e1d, + TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond => (baseUnitValue) / 1e-1d, + TemperatureChangeRateUnit.DegreeCelsiusPerMinute => baseUnitValue*60, + TemperatureChangeRateUnit.DegreeCelsiusPerSecond => baseUnitValue, + TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond => (baseUnitValue) / 1e2d, + TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond => (baseUnitValue) / 1e3d, + TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond => (baseUnitValue) / 1e-6d, + TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond => (baseUnitValue) / 1e-3d, + TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond => (baseUnitValue) / 1e-9d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureDelta.g.cs index 353f0e444c..6fe1f8f874 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -219,20 +219,19 @@ public TemperatureDelta ToUnit(TemperatureDeltaUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case TemperatureDeltaUnit.DegreeCelsius: return _value; - case TemperatureDeltaUnit.DegreeDelisle: return _value*-2/3; - case TemperatureDeltaUnit.DegreeFahrenheit: return _value*5/9; - case TemperatureDeltaUnit.DegreeNewton: return _value*100/33; - case TemperatureDeltaUnit.DegreeRankine: return _value*5/9; - case TemperatureDeltaUnit.DegreeReaumur: return _value*5/4; - case TemperatureDeltaUnit.DegreeRoemer: return _value*40/21; - case TemperatureDeltaUnit.Kelvin: return _value; - case TemperatureDeltaUnit.MillidegreeCelsius: return (_value) * 1e-3d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + TemperatureDeltaUnit.DegreeCelsius => _value, + TemperatureDeltaUnit.DegreeDelisle => _value*-2/3, + TemperatureDeltaUnit.DegreeFahrenheit => _value*5/9, + TemperatureDeltaUnit.DegreeNewton => _value*100/33, + TemperatureDeltaUnit.DegreeRankine => _value*5/9, + TemperatureDeltaUnit.DegreeReaumur => _value*5/4, + TemperatureDeltaUnit.DegreeRoemer => _value*40/21, + TemperatureDeltaUnit.Kelvin => _value, + TemperatureDeltaUnit.MillidegreeCelsius => (_value) * 1e-3d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(TemperatureDeltaUnit unit) @@ -242,20 +241,19 @@ private double GetValueAs(TemperatureDeltaUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case TemperatureDeltaUnit.DegreeCelsius: return baseUnitValue; - case TemperatureDeltaUnit.DegreeDelisle: return baseUnitValue*-3/2; - case TemperatureDeltaUnit.DegreeFahrenheit: return baseUnitValue*9/5; - case TemperatureDeltaUnit.DegreeNewton: return baseUnitValue*33/100; - case TemperatureDeltaUnit.DegreeRankine: return baseUnitValue*9/5; - case TemperatureDeltaUnit.DegreeReaumur: return baseUnitValue*4/5; - case TemperatureDeltaUnit.DegreeRoemer: return baseUnitValue*21/40; - case TemperatureDeltaUnit.Kelvin: return baseUnitValue; - case TemperatureDeltaUnit.MillidegreeCelsius: return (baseUnitValue) / 1e-3d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + TemperatureDeltaUnit.DegreeCelsius => baseUnitValue, + TemperatureDeltaUnit.DegreeDelisle => baseUnitValue*-3/2, + TemperatureDeltaUnit.DegreeFahrenheit => baseUnitValue*9/5, + TemperatureDeltaUnit.DegreeNewton => baseUnitValue*33/100, + TemperatureDeltaUnit.DegreeRankine => baseUnitValue*9/5, + TemperatureDeltaUnit.DegreeReaumur => baseUnitValue*4/5, + TemperatureDeltaUnit.DegreeRoemer => baseUnitValue*21/40, + TemperatureDeltaUnit.Kelvin => baseUnitValue, + TemperatureDeltaUnit.MillidegreeCelsius => (baseUnitValue) / 1e-3d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureGradient.g.cs index 1fe835c1ad..552865441b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -164,15 +164,14 @@ public TemperatureGradient ToUnit(TemperatureGradientUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case TemperatureGradientUnit.DegreeCelsiusPerKilometer: return _value / 1e3; - case TemperatureGradientUnit.DegreeCelsiusPerMeter: return _value; - case TemperatureGradientUnit.DegreeFahrenheitPerFoot: return (_value / 0.3048) * 5/9; - case TemperatureGradientUnit.KelvinPerMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + TemperatureGradientUnit.DegreeCelsiusPerKilometer => _value / 1e3, + TemperatureGradientUnit.DegreeCelsiusPerMeter => _value, + TemperatureGradientUnit.DegreeFahrenheitPerFoot => (_value / 0.3048) * 5/9, + TemperatureGradientUnit.KelvinPerMeter => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(TemperatureGradientUnit unit) @@ -182,15 +181,14 @@ private double GetValueAs(TemperatureGradientUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case TemperatureGradientUnit.DegreeCelsiusPerKilometer: return baseUnitValue * 1e3; - case TemperatureGradientUnit.DegreeCelsiusPerMeter: return baseUnitValue; - case TemperatureGradientUnit.DegreeFahrenheitPerFoot: return (baseUnitValue * 0.3048) * 9/5; - case TemperatureGradientUnit.KelvinPerMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + TemperatureGradientUnit.DegreeCelsiusPerKilometer => baseUnitValue * 1e3, + TemperatureGradientUnit.DegreeCelsiusPerMeter => baseUnitValue, + TemperatureGradientUnit.DegreeFahrenheitPerFoot => (baseUnitValue * 0.3048) * 9/5, + TemperatureGradientUnit.KelvinPerMeter => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalConductivity.g.cs index d1a1cc6657..e35b4d213a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -145,13 +145,12 @@ public ThermalConductivity ToUnit(ThermalConductivityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ThermalConductivityUnit.BtuPerHourFootFahrenheit: return _value*1.73073467; - case ThermalConductivityUnit.WattPerMeterKelvin: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ThermalConductivityUnit.BtuPerHourFootFahrenheit => _value*1.73073467, + ThermalConductivityUnit.WattPerMeterKelvin => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ThermalConductivityUnit unit) @@ -161,13 +160,12 @@ private double GetValueAs(ThermalConductivityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ThermalConductivityUnit.BtuPerHourFootFahrenheit: return baseUnitValue/1.73073467; - case ThermalConductivityUnit.WattPerMeterKelvin: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ThermalConductivityUnit.BtuPerHourFootFahrenheit => baseUnitValue/1.73073467, + ThermalConductivityUnit.WattPerMeterKelvin => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalResistance.g.cs index 2355680fb8..b8b43cbe37 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -186,17 +186,16 @@ public ThermalResistance ToUnit(ThermalResistanceUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu: return _value*176.1121482159839; - case ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie: return _value*0.0859779507590433; - case ThermalResistanceUnit.SquareCentimeterKelvinPerWatt: return _value*0.0999964777570357; - case ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt: return _value*1000.088056074108; - case ThermalResistanceUnit.SquareMeterKelvinPerKilowatt: return _value; - case ThermalResistanceUnit.SquareMeterKelvinPerWatt: return _value*1000; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu => _value*176.1121482159839, + ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie => _value*0.0859779507590433, + ThermalResistanceUnit.SquareCentimeterKelvinPerWatt => _value*0.0999964777570357, + ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt => _value*1000.088056074108, + ThermalResistanceUnit.SquareMeterKelvinPerKilowatt => _value, + ThermalResistanceUnit.SquareMeterKelvinPerWatt => _value*1000, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(ThermalResistanceUnit unit) @@ -206,17 +205,16 @@ private double GetValueAs(ThermalResistanceUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu: return baseUnitValue/176.1121482159839; - case ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie: return baseUnitValue/0.0859779507590433; - case ThermalResistanceUnit.SquareCentimeterKelvinPerWatt: return baseUnitValue/0.0999964777570357; - case ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt: return baseUnitValue/1000.088056074108; - case ThermalResistanceUnit.SquareMeterKelvinPerKilowatt: return baseUnitValue; - case ThermalResistanceUnit.SquareMeterKelvinPerWatt: return baseUnitValue/1000; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu => baseUnitValue/176.1121482159839, + ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie => baseUnitValue/0.0859779507590433, + ThermalResistanceUnit.SquareCentimeterKelvinPerWatt => baseUnitValue/0.0999964777570357, + ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt => baseUnitValue/1000.088056074108, + ThermalResistanceUnit.SquareMeterKelvinPerKilowatt => baseUnitValue, + ThermalResistanceUnit.SquareMeterKelvinPerWatt => baseUnitValue/1000, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Torque.g.cs index 790bfb90c5..2347ec8625 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Torque.g.cs @@ -395,36 +395,35 @@ public Torque ToUnit(TorqueUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case TorqueUnit.GramForceCentimeter: return _value*9.80665e-5; - case TorqueUnit.GramForceMeter: return _value*9.80665e-3; - case TorqueUnit.GramForceMillimeter: return _value*9.80665e-6; - case TorqueUnit.KilogramForceCentimeter: return _value*9.80665e-2; - case TorqueUnit.KilogramForceMeter: return _value*9.80665; - case TorqueUnit.KilogramForceMillimeter: return _value*9.80665e-3; - case TorqueUnit.KilonewtonCentimeter: return (_value*0.01) * 1e3d; - case TorqueUnit.KilonewtonMeter: return (_value) * 1e3d; - case TorqueUnit.KilonewtonMillimeter: return (_value*0.001) * 1e3d; - case TorqueUnit.KilopoundForceFoot: return (_value*1.3558179483314) * 1e3d; - case TorqueUnit.KilopoundForceInch: return (_value*1.129848290276167e-1) * 1e3d; - case TorqueUnit.MeganewtonCentimeter: return (_value*0.01) * 1e6d; - case TorqueUnit.MeganewtonMeter: return (_value) * 1e6d; - case TorqueUnit.MeganewtonMillimeter: return (_value*0.001) * 1e6d; - case TorqueUnit.MegapoundForceFoot: return (_value*1.3558179483314) * 1e6d; - case TorqueUnit.MegapoundForceInch: return (_value*1.129848290276167e-1) * 1e6d; - case TorqueUnit.NewtonCentimeter: return _value*0.01; - case TorqueUnit.NewtonMeter: return _value; - case TorqueUnit.NewtonMillimeter: return _value*0.001; - case TorqueUnit.PoundalFoot: return _value*4.21401100938048e-2; - case TorqueUnit.PoundForceFoot: return _value*1.3558179483314; - case TorqueUnit.PoundForceInch: return _value*1.129848290276167e-1; - case TorqueUnit.TonneForceCentimeter: return _value*9.80665e1; - case TorqueUnit.TonneForceMeter: return _value*9.80665e3; - case TorqueUnit.TonneForceMillimeter: return _value*9.80665; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + TorqueUnit.GramForceCentimeter => _value*9.80665e-5, + TorqueUnit.GramForceMeter => _value*9.80665e-3, + TorqueUnit.GramForceMillimeter => _value*9.80665e-6, + TorqueUnit.KilogramForceCentimeter => _value*9.80665e-2, + TorqueUnit.KilogramForceMeter => _value*9.80665, + TorqueUnit.KilogramForceMillimeter => _value*9.80665e-3, + TorqueUnit.KilonewtonCentimeter => (_value*0.01) * 1e3d, + TorqueUnit.KilonewtonMeter => (_value) * 1e3d, + TorqueUnit.KilonewtonMillimeter => (_value*0.001) * 1e3d, + TorqueUnit.KilopoundForceFoot => (_value*1.3558179483314) * 1e3d, + TorqueUnit.KilopoundForceInch => (_value*1.129848290276167e-1) * 1e3d, + TorqueUnit.MeganewtonCentimeter => (_value*0.01) * 1e6d, + TorqueUnit.MeganewtonMeter => (_value) * 1e6d, + TorqueUnit.MeganewtonMillimeter => (_value*0.001) * 1e6d, + TorqueUnit.MegapoundForceFoot => (_value*1.3558179483314) * 1e6d, + TorqueUnit.MegapoundForceInch => (_value*1.129848290276167e-1) * 1e6d, + TorqueUnit.NewtonCentimeter => _value*0.01, + TorqueUnit.NewtonMeter => _value, + TorqueUnit.NewtonMillimeter => _value*0.001, + TorqueUnit.PoundalFoot => _value*4.21401100938048e-2, + TorqueUnit.PoundForceFoot => _value*1.3558179483314, + TorqueUnit.PoundForceInch => _value*1.129848290276167e-1, + TorqueUnit.TonneForceCentimeter => _value*9.80665e1, + TorqueUnit.TonneForceMeter => _value*9.80665e3, + TorqueUnit.TonneForceMillimeter => _value*9.80665, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(TorqueUnit unit) @@ -434,36 +433,35 @@ private double GetValueAs(TorqueUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case TorqueUnit.GramForceCentimeter: return baseUnitValue/9.80665e-5; - case TorqueUnit.GramForceMeter: return baseUnitValue/9.80665e-3; - case TorqueUnit.GramForceMillimeter: return baseUnitValue/9.80665e-6; - case TorqueUnit.KilogramForceCentimeter: return baseUnitValue/9.80665e-2; - case TorqueUnit.KilogramForceMeter: return baseUnitValue/9.80665; - case TorqueUnit.KilogramForceMillimeter: return baseUnitValue/9.80665e-3; - case TorqueUnit.KilonewtonCentimeter: return (baseUnitValue*100) / 1e3d; - case TorqueUnit.KilonewtonMeter: return (baseUnitValue) / 1e3d; - case TorqueUnit.KilonewtonMillimeter: return (baseUnitValue*1000) / 1e3d; - case TorqueUnit.KilopoundForceFoot: return (baseUnitValue/1.3558179483314) / 1e3d; - case TorqueUnit.KilopoundForceInch: return (baseUnitValue/1.129848290276167e-1) / 1e3d; - case TorqueUnit.MeganewtonCentimeter: return (baseUnitValue*100) / 1e6d; - case TorqueUnit.MeganewtonMeter: return (baseUnitValue) / 1e6d; - case TorqueUnit.MeganewtonMillimeter: return (baseUnitValue*1000) / 1e6d; - case TorqueUnit.MegapoundForceFoot: return (baseUnitValue/1.3558179483314) / 1e6d; - case TorqueUnit.MegapoundForceInch: return (baseUnitValue/1.129848290276167e-1) / 1e6d; - case TorqueUnit.NewtonCentimeter: return baseUnitValue*100; - case TorqueUnit.NewtonMeter: return baseUnitValue; - case TorqueUnit.NewtonMillimeter: return baseUnitValue*1000; - case TorqueUnit.PoundalFoot: return baseUnitValue/4.21401100938048e-2; - case TorqueUnit.PoundForceFoot: return baseUnitValue/1.3558179483314; - case TorqueUnit.PoundForceInch: return baseUnitValue/1.129848290276167e-1; - case TorqueUnit.TonneForceCentimeter: return baseUnitValue/9.80665e1; - case TorqueUnit.TonneForceMeter: return baseUnitValue/9.80665e3; - case TorqueUnit.TonneForceMillimeter: return baseUnitValue/9.80665; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + TorqueUnit.GramForceCentimeter => baseUnitValue/9.80665e-5, + TorqueUnit.GramForceMeter => baseUnitValue/9.80665e-3, + TorqueUnit.GramForceMillimeter => baseUnitValue/9.80665e-6, + TorqueUnit.KilogramForceCentimeter => baseUnitValue/9.80665e-2, + TorqueUnit.KilogramForceMeter => baseUnitValue/9.80665, + TorqueUnit.KilogramForceMillimeter => baseUnitValue/9.80665e-3, + TorqueUnit.KilonewtonCentimeter => (baseUnitValue*100) / 1e3d, + TorqueUnit.KilonewtonMeter => (baseUnitValue) / 1e3d, + TorqueUnit.KilonewtonMillimeter => (baseUnitValue*1000) / 1e3d, + TorqueUnit.KilopoundForceFoot => (baseUnitValue/1.3558179483314) / 1e3d, + TorqueUnit.KilopoundForceInch => (baseUnitValue/1.129848290276167e-1) / 1e3d, + TorqueUnit.MeganewtonCentimeter => (baseUnitValue*100) / 1e6d, + TorqueUnit.MeganewtonMeter => (baseUnitValue) / 1e6d, + TorqueUnit.MeganewtonMillimeter => (baseUnitValue*1000) / 1e6d, + TorqueUnit.MegapoundForceFoot => (baseUnitValue/1.3558179483314) / 1e6d, + TorqueUnit.MegapoundForceInch => (baseUnitValue/1.129848290276167e-1) / 1e6d, + TorqueUnit.NewtonCentimeter => baseUnitValue*100, + TorqueUnit.NewtonMeter => baseUnitValue, + TorqueUnit.NewtonMillimeter => baseUnitValue*1000, + TorqueUnit.PoundalFoot => baseUnitValue/4.21401100938048e-2, + TorqueUnit.PoundForceFoot => baseUnitValue/1.3558179483314, + TorqueUnit.PoundForceInch => baseUnitValue/1.129848290276167e-1, + TorqueUnit.TonneForceCentimeter => baseUnitValue/9.80665e1, + TorqueUnit.TonneForceMeter => baseUnitValue/9.80665e3, + TorqueUnit.TonneForceMillimeter => baseUnitValue/9.80665, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TorquePerLength.g.cs index 2f227ac16b..a54cb24ce9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -351,32 +351,31 @@ public TorquePerLength ToUnit(TorquePerLengthUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case TorquePerLengthUnit.KilogramForceCentimeterPerMeter: return _value*0.0980665019960652; - case TorquePerLengthUnit.KilogramForceMeterPerMeter: return _value*9.80665019960652; - case TorquePerLengthUnit.KilogramForceMillimeterPerMeter: return _value*0.00980665019960652; - case TorquePerLengthUnit.KilonewtonCentimeterPerMeter: return (_value*0.01) * 1e3d; - case TorquePerLengthUnit.KilonewtonMeterPerMeter: return (_value) * 1e3d; - case TorquePerLengthUnit.KilonewtonMillimeterPerMeter: return (_value*0.001) * 1e3d; - case TorquePerLengthUnit.KilopoundForceFootPerFoot: return (_value*4.44822161526) * 1e3d; - case TorquePerLengthUnit.KilopoundForceInchPerFoot: return (_value*0.370685147638) * 1e3d; - case TorquePerLengthUnit.MeganewtonCentimeterPerMeter: return (_value*0.01) * 1e6d; - case TorquePerLengthUnit.MeganewtonMeterPerMeter: return (_value) * 1e6d; - case TorquePerLengthUnit.MeganewtonMillimeterPerMeter: return (_value*0.001) * 1e6d; - case TorquePerLengthUnit.MegapoundForceFootPerFoot: return (_value*4.44822161526) * 1e6d; - case TorquePerLengthUnit.MegapoundForceInchPerFoot: return (_value*0.370685147638) * 1e6d; - case TorquePerLengthUnit.NewtonCentimeterPerMeter: return _value*0.01; - case TorquePerLengthUnit.NewtonMeterPerMeter: return _value; - case TorquePerLengthUnit.NewtonMillimeterPerMeter: return _value*0.001; - case TorquePerLengthUnit.PoundForceFootPerFoot: return _value*4.44822161526; - case TorquePerLengthUnit.PoundForceInchPerFoot: return _value*0.370685147638; - case TorquePerLengthUnit.TonneForceCentimeterPerMeter: return _value*98.0665019960652; - case TorquePerLengthUnit.TonneForceMeterPerMeter: return _value*9806.65019960653; - case TorquePerLengthUnit.TonneForceMillimeterPerMeter: return _value*9.80665019960652; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + TorquePerLengthUnit.KilogramForceCentimeterPerMeter => _value*0.0980665019960652, + TorquePerLengthUnit.KilogramForceMeterPerMeter => _value*9.80665019960652, + TorquePerLengthUnit.KilogramForceMillimeterPerMeter => _value*0.00980665019960652, + TorquePerLengthUnit.KilonewtonCentimeterPerMeter => (_value*0.01) * 1e3d, + TorquePerLengthUnit.KilonewtonMeterPerMeter => (_value) * 1e3d, + TorquePerLengthUnit.KilonewtonMillimeterPerMeter => (_value*0.001) * 1e3d, + TorquePerLengthUnit.KilopoundForceFootPerFoot => (_value*4.44822161526) * 1e3d, + TorquePerLengthUnit.KilopoundForceInchPerFoot => (_value*0.370685147638) * 1e3d, + TorquePerLengthUnit.MeganewtonCentimeterPerMeter => (_value*0.01) * 1e6d, + TorquePerLengthUnit.MeganewtonMeterPerMeter => (_value) * 1e6d, + TorquePerLengthUnit.MeganewtonMillimeterPerMeter => (_value*0.001) * 1e6d, + TorquePerLengthUnit.MegapoundForceFootPerFoot => (_value*4.44822161526) * 1e6d, + TorquePerLengthUnit.MegapoundForceInchPerFoot => (_value*0.370685147638) * 1e6d, + TorquePerLengthUnit.NewtonCentimeterPerMeter => _value*0.01, + TorquePerLengthUnit.NewtonMeterPerMeter => _value, + TorquePerLengthUnit.NewtonMillimeterPerMeter => _value*0.001, + TorquePerLengthUnit.PoundForceFootPerFoot => _value*4.44822161526, + TorquePerLengthUnit.PoundForceInchPerFoot => _value*0.370685147638, + TorquePerLengthUnit.TonneForceCentimeterPerMeter => _value*98.0665019960652, + TorquePerLengthUnit.TonneForceMeterPerMeter => _value*9806.65019960653, + TorquePerLengthUnit.TonneForceMillimeterPerMeter => _value*9.80665019960652, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(TorquePerLengthUnit unit) @@ -386,32 +385,31 @@ private double GetValueAs(TorquePerLengthUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case TorquePerLengthUnit.KilogramForceCentimeterPerMeter: return baseUnitValue*10.1971619222242; - case TorquePerLengthUnit.KilogramForceMeterPerMeter: return baseUnitValue*0.101971619222242; - case TorquePerLengthUnit.KilogramForceMillimeterPerMeter: return baseUnitValue*101.971619222242; - case TorquePerLengthUnit.KilonewtonCentimeterPerMeter: return (baseUnitValue*100) / 1e3d; - case TorquePerLengthUnit.KilonewtonMeterPerMeter: return (baseUnitValue) / 1e3d; - case TorquePerLengthUnit.KilonewtonMillimeterPerMeter: return (baseUnitValue*1000) / 1e3d; - case TorquePerLengthUnit.KilopoundForceFootPerFoot: return (baseUnitValue/4.44822161526) / 1e3d; - case TorquePerLengthUnit.KilopoundForceInchPerFoot: return (baseUnitValue/0.370685147638) / 1e3d; - case TorquePerLengthUnit.MeganewtonCentimeterPerMeter: return (baseUnitValue*100) / 1e6d; - case TorquePerLengthUnit.MeganewtonMeterPerMeter: return (baseUnitValue) / 1e6d; - case TorquePerLengthUnit.MeganewtonMillimeterPerMeter: return (baseUnitValue*1000) / 1e6d; - case TorquePerLengthUnit.MegapoundForceFootPerFoot: return (baseUnitValue/4.44822161526) / 1e6d; - case TorquePerLengthUnit.MegapoundForceInchPerFoot: return (baseUnitValue/0.370685147638) / 1e6d; - case TorquePerLengthUnit.NewtonCentimeterPerMeter: return baseUnitValue*100; - case TorquePerLengthUnit.NewtonMeterPerMeter: return baseUnitValue; - case TorquePerLengthUnit.NewtonMillimeterPerMeter: return baseUnitValue*1000; - case TorquePerLengthUnit.PoundForceFootPerFoot: return baseUnitValue/4.44822161526; - case TorquePerLengthUnit.PoundForceInchPerFoot: return baseUnitValue/0.370685147638; - case TorquePerLengthUnit.TonneForceCentimeterPerMeter: return baseUnitValue*0.0101971619222242; - case TorquePerLengthUnit.TonneForceMeterPerMeter: return baseUnitValue*0.000101971619222242; - case TorquePerLengthUnit.TonneForceMillimeterPerMeter: return baseUnitValue*0.101971619222242; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + TorquePerLengthUnit.KilogramForceCentimeterPerMeter => baseUnitValue*10.1971619222242, + TorquePerLengthUnit.KilogramForceMeterPerMeter => baseUnitValue*0.101971619222242, + TorquePerLengthUnit.KilogramForceMillimeterPerMeter => baseUnitValue*101.971619222242, + TorquePerLengthUnit.KilonewtonCentimeterPerMeter => (baseUnitValue*100) / 1e3d, + TorquePerLengthUnit.KilonewtonMeterPerMeter => (baseUnitValue) / 1e3d, + TorquePerLengthUnit.KilonewtonMillimeterPerMeter => (baseUnitValue*1000) / 1e3d, + TorquePerLengthUnit.KilopoundForceFootPerFoot => (baseUnitValue/4.44822161526) / 1e3d, + TorquePerLengthUnit.KilopoundForceInchPerFoot => (baseUnitValue/0.370685147638) / 1e3d, + TorquePerLengthUnit.MeganewtonCentimeterPerMeter => (baseUnitValue*100) / 1e6d, + TorquePerLengthUnit.MeganewtonMeterPerMeter => (baseUnitValue) / 1e6d, + TorquePerLengthUnit.MeganewtonMillimeterPerMeter => (baseUnitValue*1000) / 1e6d, + TorquePerLengthUnit.MegapoundForceFootPerFoot => (baseUnitValue/4.44822161526) / 1e6d, + TorquePerLengthUnit.MegapoundForceInchPerFoot => (baseUnitValue/0.370685147638) / 1e6d, + TorquePerLengthUnit.NewtonCentimeterPerMeter => baseUnitValue*100, + TorquePerLengthUnit.NewtonMeterPerMeter => baseUnitValue, + TorquePerLengthUnit.NewtonMillimeterPerMeter => baseUnitValue*1000, + TorquePerLengthUnit.PoundForceFootPerFoot => baseUnitValue/4.44822161526, + TorquePerLengthUnit.PoundForceInchPerFoot => baseUnitValue/0.370685147638, + TorquePerLengthUnit.TonneForceCentimeterPerMeter => baseUnitValue*0.0101971619222242, + TorquePerLengthUnit.TonneForceMeterPerMeter => baseUnitValue*0.000101971619222242, + TorquePerLengthUnit.TonneForceMillimeterPerMeter => baseUnitValue*0.101971619222242, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Turbidity.g.cs index b11dc3345b..d271f545d1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Turbidity.g.cs @@ -134,12 +134,11 @@ public Turbidity ToUnit(TurbidityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case TurbidityUnit.NTU: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + TurbidityUnit.NTU => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(TurbidityUnit unit) @@ -149,12 +148,11 @@ private double GetValueAs(TurbidityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case TurbidityUnit.NTU: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + TurbidityUnit.NTU => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VitaminA.g.cs index 6f4792b5da..938e133fda 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VitaminA.g.cs @@ -131,12 +131,11 @@ public VitaminA ToUnit(VitaminAUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case VitaminAUnit.InternationalUnit: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + VitaminAUnit.InternationalUnit => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(VitaminAUnit unit) @@ -146,12 +145,11 @@ private double GetValueAs(VitaminAUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case VitaminAUnit.InternationalUnit: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + VitaminAUnit.InternationalUnit => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs index 77582ba5f8..39a92f1725 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs @@ -692,63 +692,62 @@ public Volume ToUnit(VolumeUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case VolumeUnit.AcreFoot: return _value/0.000810714; - case VolumeUnit.AuTablespoon: return _value*2e-5; - case VolumeUnit.BoardFoot: return _value*2.3597372158e-3; - case VolumeUnit.Centiliter: return (_value / 1e3) * 1e-2d; - case VolumeUnit.CubicCentimeter: return _value/1e6; - case VolumeUnit.CubicDecimeter: return _value/1e3; - case VolumeUnit.CubicFoot: return _value * 2.8316846592e-2; - case VolumeUnit.CubicHectometer: return _value*1e6; - case VolumeUnit.CubicInch: return _value*1.6387*1e-5; - case VolumeUnit.CubicKilometer: return _value*1e9; - case VolumeUnit.CubicMeter: return _value; - case VolumeUnit.CubicMicrometer: return _value/1e18; - case VolumeUnit.CubicMile: return _value*4.16818182544058e9; - case VolumeUnit.CubicMillimeter: return _value/1e9; - case VolumeUnit.CubicYard: return _value*0.764554858; - case VolumeUnit.Decaliter: return (_value / 1e3) * 1e1d; - case VolumeUnit.DecausGallon: return (_value*0.00378541) * 1e1d; - case VolumeUnit.Deciliter: return (_value / 1e3) * 1e-1d; - case VolumeUnit.DeciusGallon: return (_value*0.00378541) * 1e-1d; - case VolumeUnit.HectocubicFoot: return (_value * 2.8316846592e-2) * 1e2d; - case VolumeUnit.HectocubicMeter: return (_value) * 1e2d; - case VolumeUnit.Hectoliter: return (_value / 1e3) * 1e2d; - case VolumeUnit.HectousGallon: return (_value*0.00378541) * 1e2d; - case VolumeUnit.ImperialBeerBarrel: return _value*0.16365924; - case VolumeUnit.ImperialGallon: return _value*0.00454609000000181429905810072407; - case VolumeUnit.ImperialOunce: return _value*2.8413062499962901241875439064617e-5; - case VolumeUnit.ImperialPint: return _value * 5.6826125e-4; - case VolumeUnit.KilocubicFoot: return (_value * 2.8316846592e-2) * 1e3d; - case VolumeUnit.KilocubicMeter: return (_value) * 1e3d; - case VolumeUnit.KiloimperialGallon: return (_value*0.00454609000000181429905810072407) * 1e3d; - case VolumeUnit.Kiloliter: return (_value / 1e3) * 1e3d; - case VolumeUnit.KilousGallon: return (_value*0.00378541) * 1e3d; - case VolumeUnit.Liter: return _value / 1e3; - case VolumeUnit.MegacubicFoot: return (_value * 2.8316846592e-2) * 1e6d; - case VolumeUnit.MegaimperialGallon: return (_value*0.00454609000000181429905810072407) * 1e6d; - case VolumeUnit.Megaliter: return (_value / 1e3) * 1e6d; - case VolumeUnit.MegausGallon: return (_value*0.00378541) * 1e6d; - case VolumeUnit.MetricCup: return _value*0.00025; - case VolumeUnit.MetricTeaspoon: return _value*0.5e-5; - case VolumeUnit.Microliter: return (_value / 1e3) * 1e-6d; - case VolumeUnit.Milliliter: return (_value / 1e3) * 1e-3d; - case VolumeUnit.OilBarrel: return _value*0.158987294928; - case VolumeUnit.UkTablespoon: return _value*1.5e-5; - case VolumeUnit.UsBeerBarrel: return _value*0.1173477658; - case VolumeUnit.UsCustomaryCup: return _value*0.0002365882365; - case VolumeUnit.UsGallon: return _value*0.00378541; - case VolumeUnit.UsLegalCup: return _value*0.00024; - case VolumeUnit.UsOunce: return _value*2.957352956253760505068307980135e-5; - case VolumeUnit.UsPint: return _value*4.73176473e-4; - case VolumeUnit.UsQuart: return _value*9.46352946e-4; - case VolumeUnit.UsTablespoon: return _value*1.478676478125e-5; - case VolumeUnit.UsTeaspoon: return _value*4.92892159375e-6; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + VolumeUnit.AcreFoot => _value/0.000810714, + VolumeUnit.AuTablespoon => _value*2e-5, + VolumeUnit.BoardFoot => _value*2.3597372158e-3, + VolumeUnit.Centiliter => (_value / 1e3) * 1e-2d, + VolumeUnit.CubicCentimeter => _value/1e6, + VolumeUnit.CubicDecimeter => _value/1e3, + VolumeUnit.CubicFoot => _value * 2.8316846592e-2, + VolumeUnit.CubicHectometer => _value*1e6, + VolumeUnit.CubicInch => _value*1.6387*1e-5, + VolumeUnit.CubicKilometer => _value*1e9, + VolumeUnit.CubicMeter => _value, + VolumeUnit.CubicMicrometer => _value/1e18, + VolumeUnit.CubicMile => _value*4.16818182544058e9, + VolumeUnit.CubicMillimeter => _value/1e9, + VolumeUnit.CubicYard => _value*0.764554858, + VolumeUnit.Decaliter => (_value / 1e3) * 1e1d, + VolumeUnit.DecausGallon => (_value*0.00378541) * 1e1d, + VolumeUnit.Deciliter => (_value / 1e3) * 1e-1d, + VolumeUnit.DeciusGallon => (_value*0.00378541) * 1e-1d, + VolumeUnit.HectocubicFoot => (_value * 2.8316846592e-2) * 1e2d, + VolumeUnit.HectocubicMeter => (_value) * 1e2d, + VolumeUnit.Hectoliter => (_value / 1e3) * 1e2d, + VolumeUnit.HectousGallon => (_value*0.00378541) * 1e2d, + VolumeUnit.ImperialBeerBarrel => _value*0.16365924, + VolumeUnit.ImperialGallon => _value*0.00454609000000181429905810072407, + VolumeUnit.ImperialOunce => _value*2.8413062499962901241875439064617e-5, + VolumeUnit.ImperialPint => _value * 5.6826125e-4, + VolumeUnit.KilocubicFoot => (_value * 2.8316846592e-2) * 1e3d, + VolumeUnit.KilocubicMeter => (_value) * 1e3d, + VolumeUnit.KiloimperialGallon => (_value*0.00454609000000181429905810072407) * 1e3d, + VolumeUnit.Kiloliter => (_value / 1e3) * 1e3d, + VolumeUnit.KilousGallon => (_value*0.00378541) * 1e3d, + VolumeUnit.Liter => _value / 1e3, + VolumeUnit.MegacubicFoot => (_value * 2.8316846592e-2) * 1e6d, + VolumeUnit.MegaimperialGallon => (_value*0.00454609000000181429905810072407) * 1e6d, + VolumeUnit.Megaliter => (_value / 1e3) * 1e6d, + VolumeUnit.MegausGallon => (_value*0.00378541) * 1e6d, + VolumeUnit.MetricCup => _value*0.00025, + VolumeUnit.MetricTeaspoon => _value*0.5e-5, + VolumeUnit.Microliter => (_value / 1e3) * 1e-6d, + VolumeUnit.Milliliter => (_value / 1e3) * 1e-3d, + VolumeUnit.OilBarrel => _value*0.158987294928, + VolumeUnit.UkTablespoon => _value*1.5e-5, + VolumeUnit.UsBeerBarrel => _value*0.1173477658, + VolumeUnit.UsCustomaryCup => _value*0.0002365882365, + VolumeUnit.UsGallon => _value*0.00378541, + VolumeUnit.UsLegalCup => _value*0.00024, + VolumeUnit.UsOunce => _value*2.957352956253760505068307980135e-5, + VolumeUnit.UsPint => _value*4.73176473e-4, + VolumeUnit.UsQuart => _value*9.46352946e-4, + VolumeUnit.UsTablespoon => _value*1.478676478125e-5, + VolumeUnit.UsTeaspoon => _value*4.92892159375e-6, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(VolumeUnit unit) @@ -758,63 +757,62 @@ private double GetValueAs(VolumeUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case VolumeUnit.AcreFoot: return baseUnitValue*0.000810714; - case VolumeUnit.AuTablespoon: return baseUnitValue/2e-5; - case VolumeUnit.BoardFoot: return baseUnitValue/2.3597372158e-3; - case VolumeUnit.Centiliter: return (baseUnitValue * 1e3) / 1e-2d; - case VolumeUnit.CubicCentimeter: return baseUnitValue*1e6; - case VolumeUnit.CubicDecimeter: return baseUnitValue*1e3; - case VolumeUnit.CubicFoot: return baseUnitValue / 2.8316846592e-2; - case VolumeUnit.CubicHectometer: return baseUnitValue/1e6; - case VolumeUnit.CubicInch: return baseUnitValue/(1.6387*1e-5); - case VolumeUnit.CubicKilometer: return baseUnitValue/1e9; - case VolumeUnit.CubicMeter: return baseUnitValue; - case VolumeUnit.CubicMicrometer: return baseUnitValue*1e18; - case VolumeUnit.CubicMile: return baseUnitValue/4.16818182544058e9; - case VolumeUnit.CubicMillimeter: return baseUnitValue*1e9; - case VolumeUnit.CubicYard: return baseUnitValue/0.764554858; - case VolumeUnit.Decaliter: return (baseUnitValue * 1e3) / 1e1d; - case VolumeUnit.DecausGallon: return (baseUnitValue/0.00378541) / 1e1d; - case VolumeUnit.Deciliter: return (baseUnitValue * 1e3) / 1e-1d; - case VolumeUnit.DeciusGallon: return (baseUnitValue/0.00378541) / 1e-1d; - case VolumeUnit.HectocubicFoot: return (baseUnitValue / 2.8316846592e-2) / 1e2d; - case VolumeUnit.HectocubicMeter: return (baseUnitValue) / 1e2d; - case VolumeUnit.Hectoliter: return (baseUnitValue * 1e3) / 1e2d; - case VolumeUnit.HectousGallon: return (baseUnitValue/0.00378541) / 1e2d; - case VolumeUnit.ImperialBeerBarrel: return baseUnitValue/0.16365924; - case VolumeUnit.ImperialGallon: return baseUnitValue/0.00454609000000181429905810072407; - case VolumeUnit.ImperialOunce: return baseUnitValue/2.8413062499962901241875439064617e-5; - case VolumeUnit.ImperialPint: return baseUnitValue / 5.6826125e-4; - case VolumeUnit.KilocubicFoot: return (baseUnitValue / 2.8316846592e-2) / 1e3d; - case VolumeUnit.KilocubicMeter: return (baseUnitValue) / 1e3d; - case VolumeUnit.KiloimperialGallon: return (baseUnitValue/0.00454609000000181429905810072407) / 1e3d; - case VolumeUnit.Kiloliter: return (baseUnitValue * 1e3) / 1e3d; - case VolumeUnit.KilousGallon: return (baseUnitValue/0.00378541) / 1e3d; - case VolumeUnit.Liter: return baseUnitValue * 1e3; - case VolumeUnit.MegacubicFoot: return (baseUnitValue / 2.8316846592e-2) / 1e6d; - case VolumeUnit.MegaimperialGallon: return (baseUnitValue/0.00454609000000181429905810072407) / 1e6d; - case VolumeUnit.Megaliter: return (baseUnitValue * 1e3) / 1e6d; - case VolumeUnit.MegausGallon: return (baseUnitValue/0.00378541) / 1e6d; - case VolumeUnit.MetricCup: return baseUnitValue/0.00025; - case VolumeUnit.MetricTeaspoon: return baseUnitValue/0.5e-5; - case VolumeUnit.Microliter: return (baseUnitValue * 1e3) / 1e-6d; - case VolumeUnit.Milliliter: return (baseUnitValue * 1e3) / 1e-3d; - case VolumeUnit.OilBarrel: return baseUnitValue/0.158987294928; - case VolumeUnit.UkTablespoon: return baseUnitValue/1.5e-5; - case VolumeUnit.UsBeerBarrel: return baseUnitValue/0.1173477658; - case VolumeUnit.UsCustomaryCup: return baseUnitValue/0.0002365882365; - case VolumeUnit.UsGallon: return baseUnitValue/0.00378541; - case VolumeUnit.UsLegalCup: return baseUnitValue/0.00024; - case VolumeUnit.UsOunce: return baseUnitValue/2.957352956253760505068307980135e-5; - case VolumeUnit.UsPint: return baseUnitValue/4.73176473e-4; - case VolumeUnit.UsQuart: return baseUnitValue/9.46352946e-4; - case VolumeUnit.UsTablespoon: return baseUnitValue/1.478676478125e-5; - case VolumeUnit.UsTeaspoon: return baseUnitValue/4.92892159375e-6; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + VolumeUnit.AcreFoot => baseUnitValue*0.000810714, + VolumeUnit.AuTablespoon => baseUnitValue/2e-5, + VolumeUnit.BoardFoot => baseUnitValue/2.3597372158e-3, + VolumeUnit.Centiliter => (baseUnitValue * 1e3) / 1e-2d, + VolumeUnit.CubicCentimeter => baseUnitValue*1e6, + VolumeUnit.CubicDecimeter => baseUnitValue*1e3, + VolumeUnit.CubicFoot => baseUnitValue / 2.8316846592e-2, + VolumeUnit.CubicHectometer => baseUnitValue/1e6, + VolumeUnit.CubicInch => baseUnitValue/(1.6387*1e-5), + VolumeUnit.CubicKilometer => baseUnitValue/1e9, + VolumeUnit.CubicMeter => baseUnitValue, + VolumeUnit.CubicMicrometer => baseUnitValue*1e18, + VolumeUnit.CubicMile => baseUnitValue/4.16818182544058e9, + VolumeUnit.CubicMillimeter => baseUnitValue*1e9, + VolumeUnit.CubicYard => baseUnitValue/0.764554858, + VolumeUnit.Decaliter => (baseUnitValue * 1e3) / 1e1d, + VolumeUnit.DecausGallon => (baseUnitValue/0.00378541) / 1e1d, + VolumeUnit.Deciliter => (baseUnitValue * 1e3) / 1e-1d, + VolumeUnit.DeciusGallon => (baseUnitValue/0.00378541) / 1e-1d, + VolumeUnit.HectocubicFoot => (baseUnitValue / 2.8316846592e-2) / 1e2d, + VolumeUnit.HectocubicMeter => (baseUnitValue) / 1e2d, + VolumeUnit.Hectoliter => (baseUnitValue * 1e3) / 1e2d, + VolumeUnit.HectousGallon => (baseUnitValue/0.00378541) / 1e2d, + VolumeUnit.ImperialBeerBarrel => baseUnitValue/0.16365924, + VolumeUnit.ImperialGallon => baseUnitValue/0.00454609000000181429905810072407, + VolumeUnit.ImperialOunce => baseUnitValue/2.8413062499962901241875439064617e-5, + VolumeUnit.ImperialPint => baseUnitValue / 5.6826125e-4, + VolumeUnit.KilocubicFoot => (baseUnitValue / 2.8316846592e-2) / 1e3d, + VolumeUnit.KilocubicMeter => (baseUnitValue) / 1e3d, + VolumeUnit.KiloimperialGallon => (baseUnitValue/0.00454609000000181429905810072407) / 1e3d, + VolumeUnit.Kiloliter => (baseUnitValue * 1e3) / 1e3d, + VolumeUnit.KilousGallon => (baseUnitValue/0.00378541) / 1e3d, + VolumeUnit.Liter => baseUnitValue * 1e3, + VolumeUnit.MegacubicFoot => (baseUnitValue / 2.8316846592e-2) / 1e6d, + VolumeUnit.MegaimperialGallon => (baseUnitValue/0.00454609000000181429905810072407) / 1e6d, + VolumeUnit.Megaliter => (baseUnitValue * 1e3) / 1e6d, + VolumeUnit.MegausGallon => (baseUnitValue/0.00378541) / 1e6d, + VolumeUnit.MetricCup => baseUnitValue/0.00025, + VolumeUnit.MetricTeaspoon => baseUnitValue/0.5e-5, + VolumeUnit.Microliter => (baseUnitValue * 1e3) / 1e-6d, + VolumeUnit.Milliliter => (baseUnitValue * 1e3) / 1e-3d, + VolumeUnit.OilBarrel => baseUnitValue/0.158987294928, + VolumeUnit.UkTablespoon => baseUnitValue/1.5e-5, + VolumeUnit.UsBeerBarrel => baseUnitValue/0.1173477658, + VolumeUnit.UsCustomaryCup => baseUnitValue/0.0002365882365, + VolumeUnit.UsGallon => baseUnitValue/0.00378541, + VolumeUnit.UsLegalCup => baseUnitValue/0.00024, + VolumeUnit.UsOunce => baseUnitValue/2.957352956253760505068307980135e-5, + VolumeUnit.UsPint => baseUnitValue/4.73176473e-4, + VolumeUnit.UsQuart => baseUnitValue/9.46352946e-4, + VolumeUnit.UsTablespoon => baseUnitValue/1.478676478125e-5, + VolumeUnit.UsTeaspoon => baseUnitValue/4.92892159375e-6, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeConcentration.g.cs index d1db57d7f3..a6eda02a1a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -343,31 +343,30 @@ public VolumeConcentration ToUnit(VolumeConcentrationUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case VolumeConcentrationUnit.CentilitersPerLiter: return (_value) * 1e-2d; - case VolumeConcentrationUnit.CentilitersPerMililiter: return (_value/1e-3) * 1e-2d; - case VolumeConcentrationUnit.DecilitersPerLiter: return (_value) * 1e-1d; - case VolumeConcentrationUnit.DecilitersPerMililiter: return (_value/1e-3) * 1e-1d; - case VolumeConcentrationUnit.DecimalFraction: return _value; - case VolumeConcentrationUnit.LitersPerLiter: return _value; - case VolumeConcentrationUnit.LitersPerMililiter: return _value/1e-3; - case VolumeConcentrationUnit.MicrolitersPerLiter: return (_value) * 1e-6d; - case VolumeConcentrationUnit.MicrolitersPerMililiter: return (_value/1e-3) * 1e-6d; - case VolumeConcentrationUnit.MillilitersPerLiter: return (_value) * 1e-3d; - case VolumeConcentrationUnit.MillilitersPerMililiter: return (_value/1e-3) * 1e-3d; - case VolumeConcentrationUnit.NanolitersPerLiter: return (_value) * 1e-9d; - case VolumeConcentrationUnit.NanolitersPerMililiter: return (_value/1e-3) * 1e-9d; - case VolumeConcentrationUnit.PartPerBillion: return _value/1e9; - case VolumeConcentrationUnit.PartPerMillion: return _value/1e6; - case VolumeConcentrationUnit.PartPerThousand: return _value/1e3; - case VolumeConcentrationUnit.PartPerTrillion: return _value/1e12; - case VolumeConcentrationUnit.Percent: return _value/1e2; - case VolumeConcentrationUnit.PicolitersPerLiter: return (_value) * 1e-12d; - case VolumeConcentrationUnit.PicolitersPerMililiter: return (_value/1e-3) * 1e-12d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + VolumeConcentrationUnit.CentilitersPerLiter => (_value) * 1e-2d, + VolumeConcentrationUnit.CentilitersPerMililiter => (_value/1e-3) * 1e-2d, + VolumeConcentrationUnit.DecilitersPerLiter => (_value) * 1e-1d, + VolumeConcentrationUnit.DecilitersPerMililiter => (_value/1e-3) * 1e-1d, + VolumeConcentrationUnit.DecimalFraction => _value, + VolumeConcentrationUnit.LitersPerLiter => _value, + VolumeConcentrationUnit.LitersPerMililiter => _value/1e-3, + VolumeConcentrationUnit.MicrolitersPerLiter => (_value) * 1e-6d, + VolumeConcentrationUnit.MicrolitersPerMililiter => (_value/1e-3) * 1e-6d, + VolumeConcentrationUnit.MillilitersPerLiter => (_value) * 1e-3d, + VolumeConcentrationUnit.MillilitersPerMililiter => (_value/1e-3) * 1e-3d, + VolumeConcentrationUnit.NanolitersPerLiter => (_value) * 1e-9d, + VolumeConcentrationUnit.NanolitersPerMililiter => (_value/1e-3) * 1e-9d, + VolumeConcentrationUnit.PartPerBillion => _value/1e9, + VolumeConcentrationUnit.PartPerMillion => _value/1e6, + VolumeConcentrationUnit.PartPerThousand => _value/1e3, + VolumeConcentrationUnit.PartPerTrillion => _value/1e12, + VolumeConcentrationUnit.Percent => _value/1e2, + VolumeConcentrationUnit.PicolitersPerLiter => (_value) * 1e-12d, + VolumeConcentrationUnit.PicolitersPerMililiter => (_value/1e-3) * 1e-12d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(VolumeConcentrationUnit unit) @@ -377,31 +376,30 @@ private double GetValueAs(VolumeConcentrationUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case VolumeConcentrationUnit.CentilitersPerLiter: return (baseUnitValue) / 1e-2d; - case VolumeConcentrationUnit.CentilitersPerMililiter: return (baseUnitValue*1e-3) / 1e-2d; - case VolumeConcentrationUnit.DecilitersPerLiter: return (baseUnitValue) / 1e-1d; - case VolumeConcentrationUnit.DecilitersPerMililiter: return (baseUnitValue*1e-3) / 1e-1d; - case VolumeConcentrationUnit.DecimalFraction: return baseUnitValue; - case VolumeConcentrationUnit.LitersPerLiter: return baseUnitValue; - case VolumeConcentrationUnit.LitersPerMililiter: return baseUnitValue*1e-3; - case VolumeConcentrationUnit.MicrolitersPerLiter: return (baseUnitValue) / 1e-6d; - case VolumeConcentrationUnit.MicrolitersPerMililiter: return (baseUnitValue*1e-3) / 1e-6d; - case VolumeConcentrationUnit.MillilitersPerLiter: return (baseUnitValue) / 1e-3d; - case VolumeConcentrationUnit.MillilitersPerMililiter: return (baseUnitValue*1e-3) / 1e-3d; - case VolumeConcentrationUnit.NanolitersPerLiter: return (baseUnitValue) / 1e-9d; - case VolumeConcentrationUnit.NanolitersPerMililiter: return (baseUnitValue*1e-3) / 1e-9d; - case VolumeConcentrationUnit.PartPerBillion: return baseUnitValue*1e9; - case VolumeConcentrationUnit.PartPerMillion: return baseUnitValue*1e6; - case VolumeConcentrationUnit.PartPerThousand: return baseUnitValue*1e3; - case VolumeConcentrationUnit.PartPerTrillion: return baseUnitValue*1e12; - case VolumeConcentrationUnit.Percent: return baseUnitValue*1e2; - case VolumeConcentrationUnit.PicolitersPerLiter: return (baseUnitValue) / 1e-12d; - case VolumeConcentrationUnit.PicolitersPerMililiter: return (baseUnitValue*1e-3) / 1e-12d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + VolumeConcentrationUnit.CentilitersPerLiter => (baseUnitValue) / 1e-2d, + VolumeConcentrationUnit.CentilitersPerMililiter => (baseUnitValue*1e-3) / 1e-2d, + VolumeConcentrationUnit.DecilitersPerLiter => (baseUnitValue) / 1e-1d, + VolumeConcentrationUnit.DecilitersPerMililiter => (baseUnitValue*1e-3) / 1e-1d, + VolumeConcentrationUnit.DecimalFraction => baseUnitValue, + VolumeConcentrationUnit.LitersPerLiter => baseUnitValue, + VolumeConcentrationUnit.LitersPerMililiter => baseUnitValue*1e-3, + VolumeConcentrationUnit.MicrolitersPerLiter => (baseUnitValue) / 1e-6d, + VolumeConcentrationUnit.MicrolitersPerMililiter => (baseUnitValue*1e-3) / 1e-6d, + VolumeConcentrationUnit.MillilitersPerLiter => (baseUnitValue) / 1e-3d, + VolumeConcentrationUnit.MillilitersPerMililiter => (baseUnitValue*1e-3) / 1e-3d, + VolumeConcentrationUnit.NanolitersPerLiter => (baseUnitValue) / 1e-9d, + VolumeConcentrationUnit.NanolitersPerMililiter => (baseUnitValue*1e-3) / 1e-9d, + VolumeConcentrationUnit.PartPerBillion => baseUnitValue*1e9, + VolumeConcentrationUnit.PartPerMillion => baseUnitValue*1e6, + VolumeConcentrationUnit.PartPerThousand => baseUnitValue*1e3, + VolumeConcentrationUnit.PartPerTrillion => baseUnitValue*1e12, + VolumeConcentrationUnit.Percent => baseUnitValue*1e2, + VolumeConcentrationUnit.PicolitersPerLiter => (baseUnitValue) / 1e-12d, + VolumeConcentrationUnit.PicolitersPerMililiter => (baseUnitValue*1e-3) / 1e-12d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs index 95376fd281..f696245393 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -802,73 +802,72 @@ public VolumeFlow ToUnit(VolumeFlowUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case VolumeFlowUnit.AcreFootPerDay: return _value/70.0457; - case VolumeFlowUnit.AcreFootPerHour: return _value/2.91857; - case VolumeFlowUnit.AcreFootPerMinute: return _value/0.0486427916; - case VolumeFlowUnit.AcreFootPerSecond: return _value/0.000810713194; - case VolumeFlowUnit.CentiliterPerDay: return (_value/86400000) * 1e-2d; - case VolumeFlowUnit.CentiliterPerHour: return (_value/3600000.000) * 1e-2d; - case VolumeFlowUnit.CentiliterPerMinute: return (_value/60000.00000) * 1e-2d; - case VolumeFlowUnit.CentiliterPerSecond: return (_value/1000) * 1e-2d; - case VolumeFlowUnit.CubicCentimeterPerMinute: return _value*1.6666666666667e-8; - case VolumeFlowUnit.CubicDecimeterPerMinute: return _value/60000.00000; - case VolumeFlowUnit.CubicFootPerHour: return _value*7.8657907199999087346816086183876e-6; - case VolumeFlowUnit.CubicFootPerMinute: return _value/2118.88000326; - case VolumeFlowUnit.CubicFootPerSecond: return _value/35.314666721; - case VolumeFlowUnit.CubicMeterPerDay: return _value/86400; - case VolumeFlowUnit.CubicMeterPerHour: return _value/3600; - case VolumeFlowUnit.CubicMeterPerMinute: return _value/60; - case VolumeFlowUnit.CubicMeterPerSecond: return _value; - case VolumeFlowUnit.CubicMillimeterPerSecond: return _value*1e-9; - case VolumeFlowUnit.CubicYardPerDay: return _value/113007; - case VolumeFlowUnit.CubicYardPerHour: return _value*2.1237634944E-4; - case VolumeFlowUnit.CubicYardPerMinute: return _value*0.0127425809664; - case VolumeFlowUnit.CubicYardPerSecond: return _value*0.764554857984; - case VolumeFlowUnit.DeciliterPerDay: return (_value/86400000) * 1e-1d; - case VolumeFlowUnit.DeciliterPerHour: return (_value/3600000.000) * 1e-1d; - case VolumeFlowUnit.DeciliterPerMinute: return (_value/60000.00000) * 1e-1d; - case VolumeFlowUnit.DeciliterPerSecond: return (_value/1000) * 1e-1d; - case VolumeFlowUnit.KiloliterPerDay: return (_value/86400000) * 1e3d; - case VolumeFlowUnit.KiloliterPerHour: return (_value/3600000.000) * 1e3d; - case VolumeFlowUnit.KiloliterPerMinute: return (_value/60000.00000) * 1e3d; - case VolumeFlowUnit.KiloliterPerSecond: return (_value/1000) * 1e3d; - case VolumeFlowUnit.KilousGallonPerMinute: return _value/15.850323141489; - case VolumeFlowUnit.LiterPerDay: return _value/86400000; - case VolumeFlowUnit.LiterPerHour: return _value/3600000.000; - case VolumeFlowUnit.LiterPerMinute: return _value/60000.00000; - case VolumeFlowUnit.LiterPerSecond: return _value/1000; - case VolumeFlowUnit.MegaliterPerDay: return (_value/86400000) * 1e6d; - case VolumeFlowUnit.MegaukGallonPerSecond: return (_value/219.969) * 1e6d; - case VolumeFlowUnit.MicroliterPerDay: return (_value/86400000) * 1e-6d; - case VolumeFlowUnit.MicroliterPerHour: return (_value/3600000.000) * 1e-6d; - case VolumeFlowUnit.MicroliterPerMinute: return (_value/60000.00000) * 1e-6d; - case VolumeFlowUnit.MicroliterPerSecond: return (_value/1000) * 1e-6d; - case VolumeFlowUnit.MilliliterPerDay: return (_value/86400000) * 1e-3d; - case VolumeFlowUnit.MilliliterPerHour: return (_value/3600000.000) * 1e-3d; - case VolumeFlowUnit.MilliliterPerMinute: return (_value/60000.00000) * 1e-3d; - case VolumeFlowUnit.MilliliterPerSecond: return (_value/1000) * 1e-3d; - case VolumeFlowUnit.MillionUsGallonsPerDay: return _value/22.824465227; - case VolumeFlowUnit.NanoliterPerDay: return (_value/86400000) * 1e-9d; - case VolumeFlowUnit.NanoliterPerHour: return (_value/3600000.000) * 1e-9d; - case VolumeFlowUnit.NanoliterPerMinute: return (_value/60000.00000) * 1e-9d; - case VolumeFlowUnit.NanoliterPerSecond: return (_value/1000) * 1e-9d; - case VolumeFlowUnit.OilBarrelPerDay: return _value*1.8401307283333333333333333333333e-6; - case VolumeFlowUnit.OilBarrelPerHour: return _value*4.41631375e-5; - case VolumeFlowUnit.OilBarrelPerMinute: return _value*2.64978825e-3; - case VolumeFlowUnit.OilBarrelPerSecond: return _value/6.28981; - case VolumeFlowUnit.UkGallonPerDay: return _value/19005304; - case VolumeFlowUnit.UkGallonPerHour: return _value/791887.667; - case VolumeFlowUnit.UkGallonPerMinute: return _value/13198.2; - case VolumeFlowUnit.UkGallonPerSecond: return _value/219.969; - case VolumeFlowUnit.UsGallonPerDay: return _value/22824465.227; - case VolumeFlowUnit.UsGallonPerHour: return _value/951019.38848933424; - case VolumeFlowUnit.UsGallonPerMinute: return _value/15850.323141489; - case VolumeFlowUnit.UsGallonPerSecond: return _value/264.1720523581484; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + VolumeFlowUnit.AcreFootPerDay => _value/70.0457, + VolumeFlowUnit.AcreFootPerHour => _value/2.91857, + VolumeFlowUnit.AcreFootPerMinute => _value/0.0486427916, + VolumeFlowUnit.AcreFootPerSecond => _value/0.000810713194, + VolumeFlowUnit.CentiliterPerDay => (_value/86400000) * 1e-2d, + VolumeFlowUnit.CentiliterPerHour => (_value/3600000.000) * 1e-2d, + VolumeFlowUnit.CentiliterPerMinute => (_value/60000.00000) * 1e-2d, + VolumeFlowUnit.CentiliterPerSecond => (_value/1000) * 1e-2d, + VolumeFlowUnit.CubicCentimeterPerMinute => _value*1.6666666666667e-8, + VolumeFlowUnit.CubicDecimeterPerMinute => _value/60000.00000, + VolumeFlowUnit.CubicFootPerHour => _value*7.8657907199999087346816086183876e-6, + VolumeFlowUnit.CubicFootPerMinute => _value/2118.88000326, + VolumeFlowUnit.CubicFootPerSecond => _value/35.314666721, + VolumeFlowUnit.CubicMeterPerDay => _value/86400, + VolumeFlowUnit.CubicMeterPerHour => _value/3600, + VolumeFlowUnit.CubicMeterPerMinute => _value/60, + VolumeFlowUnit.CubicMeterPerSecond => _value, + VolumeFlowUnit.CubicMillimeterPerSecond => _value*1e-9, + VolumeFlowUnit.CubicYardPerDay => _value/113007, + VolumeFlowUnit.CubicYardPerHour => _value*2.1237634944E-4, + VolumeFlowUnit.CubicYardPerMinute => _value*0.0127425809664, + VolumeFlowUnit.CubicYardPerSecond => _value*0.764554857984, + VolumeFlowUnit.DeciliterPerDay => (_value/86400000) * 1e-1d, + VolumeFlowUnit.DeciliterPerHour => (_value/3600000.000) * 1e-1d, + VolumeFlowUnit.DeciliterPerMinute => (_value/60000.00000) * 1e-1d, + VolumeFlowUnit.DeciliterPerSecond => (_value/1000) * 1e-1d, + VolumeFlowUnit.KiloliterPerDay => (_value/86400000) * 1e3d, + VolumeFlowUnit.KiloliterPerHour => (_value/3600000.000) * 1e3d, + VolumeFlowUnit.KiloliterPerMinute => (_value/60000.00000) * 1e3d, + VolumeFlowUnit.KiloliterPerSecond => (_value/1000) * 1e3d, + VolumeFlowUnit.KilousGallonPerMinute => _value/15.850323141489, + VolumeFlowUnit.LiterPerDay => _value/86400000, + VolumeFlowUnit.LiterPerHour => _value/3600000.000, + VolumeFlowUnit.LiterPerMinute => _value/60000.00000, + VolumeFlowUnit.LiterPerSecond => _value/1000, + VolumeFlowUnit.MegaliterPerDay => (_value/86400000) * 1e6d, + VolumeFlowUnit.MegaukGallonPerSecond => (_value/219.969) * 1e6d, + VolumeFlowUnit.MicroliterPerDay => (_value/86400000) * 1e-6d, + VolumeFlowUnit.MicroliterPerHour => (_value/3600000.000) * 1e-6d, + VolumeFlowUnit.MicroliterPerMinute => (_value/60000.00000) * 1e-6d, + VolumeFlowUnit.MicroliterPerSecond => (_value/1000) * 1e-6d, + VolumeFlowUnit.MilliliterPerDay => (_value/86400000) * 1e-3d, + VolumeFlowUnit.MilliliterPerHour => (_value/3600000.000) * 1e-3d, + VolumeFlowUnit.MilliliterPerMinute => (_value/60000.00000) * 1e-3d, + VolumeFlowUnit.MilliliterPerSecond => (_value/1000) * 1e-3d, + VolumeFlowUnit.MillionUsGallonsPerDay => _value/22.824465227, + VolumeFlowUnit.NanoliterPerDay => (_value/86400000) * 1e-9d, + VolumeFlowUnit.NanoliterPerHour => (_value/3600000.000) * 1e-9d, + VolumeFlowUnit.NanoliterPerMinute => (_value/60000.00000) * 1e-9d, + VolumeFlowUnit.NanoliterPerSecond => (_value/1000) * 1e-9d, + VolumeFlowUnit.OilBarrelPerDay => _value*1.8401307283333333333333333333333e-6, + VolumeFlowUnit.OilBarrelPerHour => _value*4.41631375e-5, + VolumeFlowUnit.OilBarrelPerMinute => _value*2.64978825e-3, + VolumeFlowUnit.OilBarrelPerSecond => _value/6.28981, + VolumeFlowUnit.UkGallonPerDay => _value/19005304, + VolumeFlowUnit.UkGallonPerHour => _value/791887.667, + VolumeFlowUnit.UkGallonPerMinute => _value/13198.2, + VolumeFlowUnit.UkGallonPerSecond => _value/219.969, + VolumeFlowUnit.UsGallonPerDay => _value/22824465.227, + VolumeFlowUnit.UsGallonPerHour => _value/951019.38848933424, + VolumeFlowUnit.UsGallonPerMinute => _value/15850.323141489, + VolumeFlowUnit.UsGallonPerSecond => _value/264.1720523581484, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(VolumeFlowUnit unit) @@ -878,73 +877,72 @@ private double GetValueAs(VolumeFlowUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case VolumeFlowUnit.AcreFootPerDay: return baseUnitValue*70.0457; - case VolumeFlowUnit.AcreFootPerHour: return baseUnitValue*2.91857; - case VolumeFlowUnit.AcreFootPerMinute: return baseUnitValue*0.0486427916; - case VolumeFlowUnit.AcreFootPerSecond: return baseUnitValue*0.000810713194; - case VolumeFlowUnit.CentiliterPerDay: return (baseUnitValue*86400000) / 1e-2d; - case VolumeFlowUnit.CentiliterPerHour: return (baseUnitValue*3600000.000) / 1e-2d; - case VolumeFlowUnit.CentiliterPerMinute: return (baseUnitValue*60000.00000) / 1e-2d; - case VolumeFlowUnit.CentiliterPerSecond: return (baseUnitValue*1000) / 1e-2d; - case VolumeFlowUnit.CubicCentimeterPerMinute: return baseUnitValue/1.6666666666667e-8; - case VolumeFlowUnit.CubicDecimeterPerMinute: return baseUnitValue*60000.00000; - case VolumeFlowUnit.CubicFootPerHour: return baseUnitValue/7.8657907199999087346816086183876e-6; - case VolumeFlowUnit.CubicFootPerMinute: return baseUnitValue*2118.88000326; - case VolumeFlowUnit.CubicFootPerSecond: return baseUnitValue*35.314666721; - case VolumeFlowUnit.CubicMeterPerDay: return baseUnitValue*86400; - case VolumeFlowUnit.CubicMeterPerHour: return baseUnitValue*3600; - case VolumeFlowUnit.CubicMeterPerMinute: return baseUnitValue*60; - case VolumeFlowUnit.CubicMeterPerSecond: return baseUnitValue; - case VolumeFlowUnit.CubicMillimeterPerSecond: return baseUnitValue/1e-9; - case VolumeFlowUnit.CubicYardPerDay: return baseUnitValue*113007; - case VolumeFlowUnit.CubicYardPerHour: return baseUnitValue/2.1237634944E-4; - case VolumeFlowUnit.CubicYardPerMinute: return baseUnitValue/0.0127425809664; - case VolumeFlowUnit.CubicYardPerSecond: return baseUnitValue/0.764554857984; - case VolumeFlowUnit.DeciliterPerDay: return (baseUnitValue*86400000) / 1e-1d; - case VolumeFlowUnit.DeciliterPerHour: return (baseUnitValue*3600000.000) / 1e-1d; - case VolumeFlowUnit.DeciliterPerMinute: return (baseUnitValue*60000.00000) / 1e-1d; - case VolumeFlowUnit.DeciliterPerSecond: return (baseUnitValue*1000) / 1e-1d; - case VolumeFlowUnit.KiloliterPerDay: return (baseUnitValue*86400000) / 1e3d; - case VolumeFlowUnit.KiloliterPerHour: return (baseUnitValue*3600000.000) / 1e3d; - case VolumeFlowUnit.KiloliterPerMinute: return (baseUnitValue*60000.00000) / 1e3d; - case VolumeFlowUnit.KiloliterPerSecond: return (baseUnitValue*1000) / 1e3d; - case VolumeFlowUnit.KilousGallonPerMinute: return baseUnitValue*15.850323141489; - case VolumeFlowUnit.LiterPerDay: return baseUnitValue*86400000; - case VolumeFlowUnit.LiterPerHour: return baseUnitValue*3600000.000; - case VolumeFlowUnit.LiterPerMinute: return baseUnitValue*60000.00000; - case VolumeFlowUnit.LiterPerSecond: return baseUnitValue*1000; - case VolumeFlowUnit.MegaliterPerDay: return (baseUnitValue*86400000) / 1e6d; - case VolumeFlowUnit.MegaukGallonPerSecond: return (baseUnitValue*219.969) / 1e6d; - case VolumeFlowUnit.MicroliterPerDay: return (baseUnitValue*86400000) / 1e-6d; - case VolumeFlowUnit.MicroliterPerHour: return (baseUnitValue*3600000.000) / 1e-6d; - case VolumeFlowUnit.MicroliterPerMinute: return (baseUnitValue*60000.00000) / 1e-6d; - case VolumeFlowUnit.MicroliterPerSecond: return (baseUnitValue*1000) / 1e-6d; - case VolumeFlowUnit.MilliliterPerDay: return (baseUnitValue*86400000) / 1e-3d; - case VolumeFlowUnit.MilliliterPerHour: return (baseUnitValue*3600000.000) / 1e-3d; - case VolumeFlowUnit.MilliliterPerMinute: return (baseUnitValue*60000.00000) / 1e-3d; - case VolumeFlowUnit.MilliliterPerSecond: return (baseUnitValue*1000) / 1e-3d; - case VolumeFlowUnit.MillionUsGallonsPerDay: return baseUnitValue*22.824465227; - case VolumeFlowUnit.NanoliterPerDay: return (baseUnitValue*86400000) / 1e-9d; - case VolumeFlowUnit.NanoliterPerHour: return (baseUnitValue*3600000.000) / 1e-9d; - case VolumeFlowUnit.NanoliterPerMinute: return (baseUnitValue*60000.00000) / 1e-9d; - case VolumeFlowUnit.NanoliterPerSecond: return (baseUnitValue*1000) / 1e-9d; - case VolumeFlowUnit.OilBarrelPerDay: return baseUnitValue/1.8401307283333333333333333333333e-6; - case VolumeFlowUnit.OilBarrelPerHour: return baseUnitValue/4.41631375e-5; - case VolumeFlowUnit.OilBarrelPerMinute: return baseUnitValue/2.64978825e-3; - case VolumeFlowUnit.OilBarrelPerSecond: return baseUnitValue*6.28981; - case VolumeFlowUnit.UkGallonPerDay: return baseUnitValue*19005304; - case VolumeFlowUnit.UkGallonPerHour: return baseUnitValue*791887.667; - case VolumeFlowUnit.UkGallonPerMinute: return baseUnitValue*13198.2; - case VolumeFlowUnit.UkGallonPerSecond: return baseUnitValue*219.969; - case VolumeFlowUnit.UsGallonPerDay: return baseUnitValue*22824465.227; - case VolumeFlowUnit.UsGallonPerHour: return baseUnitValue*951019.38848933424; - case VolumeFlowUnit.UsGallonPerMinute: return baseUnitValue*15850.323141489; - case VolumeFlowUnit.UsGallonPerSecond: return baseUnitValue*264.1720523581484; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + VolumeFlowUnit.AcreFootPerDay => baseUnitValue*70.0457, + VolumeFlowUnit.AcreFootPerHour => baseUnitValue*2.91857, + VolumeFlowUnit.AcreFootPerMinute => baseUnitValue*0.0486427916, + VolumeFlowUnit.AcreFootPerSecond => baseUnitValue*0.000810713194, + VolumeFlowUnit.CentiliterPerDay => (baseUnitValue*86400000) / 1e-2d, + VolumeFlowUnit.CentiliterPerHour => (baseUnitValue*3600000.000) / 1e-2d, + VolumeFlowUnit.CentiliterPerMinute => (baseUnitValue*60000.00000) / 1e-2d, + VolumeFlowUnit.CentiliterPerSecond => (baseUnitValue*1000) / 1e-2d, + VolumeFlowUnit.CubicCentimeterPerMinute => baseUnitValue/1.6666666666667e-8, + VolumeFlowUnit.CubicDecimeterPerMinute => baseUnitValue*60000.00000, + VolumeFlowUnit.CubicFootPerHour => baseUnitValue/7.8657907199999087346816086183876e-6, + VolumeFlowUnit.CubicFootPerMinute => baseUnitValue*2118.88000326, + VolumeFlowUnit.CubicFootPerSecond => baseUnitValue*35.314666721, + VolumeFlowUnit.CubicMeterPerDay => baseUnitValue*86400, + VolumeFlowUnit.CubicMeterPerHour => baseUnitValue*3600, + VolumeFlowUnit.CubicMeterPerMinute => baseUnitValue*60, + VolumeFlowUnit.CubicMeterPerSecond => baseUnitValue, + VolumeFlowUnit.CubicMillimeterPerSecond => baseUnitValue/1e-9, + VolumeFlowUnit.CubicYardPerDay => baseUnitValue*113007, + VolumeFlowUnit.CubicYardPerHour => baseUnitValue/2.1237634944E-4, + VolumeFlowUnit.CubicYardPerMinute => baseUnitValue/0.0127425809664, + VolumeFlowUnit.CubicYardPerSecond => baseUnitValue/0.764554857984, + VolumeFlowUnit.DeciliterPerDay => (baseUnitValue*86400000) / 1e-1d, + VolumeFlowUnit.DeciliterPerHour => (baseUnitValue*3600000.000) / 1e-1d, + VolumeFlowUnit.DeciliterPerMinute => (baseUnitValue*60000.00000) / 1e-1d, + VolumeFlowUnit.DeciliterPerSecond => (baseUnitValue*1000) / 1e-1d, + VolumeFlowUnit.KiloliterPerDay => (baseUnitValue*86400000) / 1e3d, + VolumeFlowUnit.KiloliterPerHour => (baseUnitValue*3600000.000) / 1e3d, + VolumeFlowUnit.KiloliterPerMinute => (baseUnitValue*60000.00000) / 1e3d, + VolumeFlowUnit.KiloliterPerSecond => (baseUnitValue*1000) / 1e3d, + VolumeFlowUnit.KilousGallonPerMinute => baseUnitValue*15.850323141489, + VolumeFlowUnit.LiterPerDay => baseUnitValue*86400000, + VolumeFlowUnit.LiterPerHour => baseUnitValue*3600000.000, + VolumeFlowUnit.LiterPerMinute => baseUnitValue*60000.00000, + VolumeFlowUnit.LiterPerSecond => baseUnitValue*1000, + VolumeFlowUnit.MegaliterPerDay => (baseUnitValue*86400000) / 1e6d, + VolumeFlowUnit.MegaukGallonPerSecond => (baseUnitValue*219.969) / 1e6d, + VolumeFlowUnit.MicroliterPerDay => (baseUnitValue*86400000) / 1e-6d, + VolumeFlowUnit.MicroliterPerHour => (baseUnitValue*3600000.000) / 1e-6d, + VolumeFlowUnit.MicroliterPerMinute => (baseUnitValue*60000.00000) / 1e-6d, + VolumeFlowUnit.MicroliterPerSecond => (baseUnitValue*1000) / 1e-6d, + VolumeFlowUnit.MilliliterPerDay => (baseUnitValue*86400000) / 1e-3d, + VolumeFlowUnit.MilliliterPerHour => (baseUnitValue*3600000.000) / 1e-3d, + VolumeFlowUnit.MilliliterPerMinute => (baseUnitValue*60000.00000) / 1e-3d, + VolumeFlowUnit.MilliliterPerSecond => (baseUnitValue*1000) / 1e-3d, + VolumeFlowUnit.MillionUsGallonsPerDay => baseUnitValue*22.824465227, + VolumeFlowUnit.NanoliterPerDay => (baseUnitValue*86400000) / 1e-9d, + VolumeFlowUnit.NanoliterPerHour => (baseUnitValue*3600000.000) / 1e-9d, + VolumeFlowUnit.NanoliterPerMinute => (baseUnitValue*60000.00000) / 1e-9d, + VolumeFlowUnit.NanoliterPerSecond => (baseUnitValue*1000) / 1e-9d, + VolumeFlowUnit.OilBarrelPerDay => baseUnitValue/1.8401307283333333333333333333333e-6, + VolumeFlowUnit.OilBarrelPerHour => baseUnitValue/4.41631375e-5, + VolumeFlowUnit.OilBarrelPerMinute => baseUnitValue/2.64978825e-3, + VolumeFlowUnit.OilBarrelPerSecond => baseUnitValue*6.28981, + VolumeFlowUnit.UkGallonPerDay => baseUnitValue*19005304, + VolumeFlowUnit.UkGallonPerHour => baseUnitValue*791887.667, + VolumeFlowUnit.UkGallonPerMinute => baseUnitValue*13198.2, + VolumeFlowUnit.UkGallonPerSecond => baseUnitValue*219.969, + VolumeFlowUnit.UsGallonPerDay => baseUnitValue*22824465.227, + VolumeFlowUnit.UsGallonPerHour => baseUnitValue*951019.38848933424, + VolumeFlowUnit.UsGallonPerMinute => baseUnitValue*15850.323141489, + VolumeFlowUnit.UsGallonPerSecond => baseUnitValue*264.1720523581484, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs index a34549e24d..99b98558a9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs @@ -142,13 +142,12 @@ public VolumeFlowPerArea ToUnit(VolumeFlowPerAreaUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot: return _value/196.850394; - case VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot => _value/196.850394, + VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(VolumeFlowPerAreaUnit unit) @@ -158,13 +157,12 @@ private double GetValueAs(VolumeFlowPerAreaUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot: return baseUnitValue*196.850394; - case VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot => baseUnitValue*196.850394, + VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumePerLength.g.cs index 48dc3d78bd..1ee4aa8afc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -197,18 +197,17 @@ public VolumePerLength ToUnit(VolumePerLengthUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case VolumePerLengthUnit.CubicMeterPerMeter: return _value; - case VolumePerLengthUnit.CubicYardPerFoot: return _value*2.50838208; - case VolumePerLengthUnit.CubicYardPerUsSurveyFoot: return _value*2.50837706323584; - case VolumePerLengthUnit.LiterPerKilometer: return _value/1e6; - case VolumePerLengthUnit.LiterPerMeter: return _value/1000; - case VolumePerLengthUnit.LiterPerMillimeter: return _value; - case VolumePerLengthUnit.OilBarrelPerFoot: return _value/1.91713408; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + VolumePerLengthUnit.CubicMeterPerMeter => _value, + VolumePerLengthUnit.CubicYardPerFoot => _value*2.50838208, + VolumePerLengthUnit.CubicYardPerUsSurveyFoot => _value*2.50837706323584, + VolumePerLengthUnit.LiterPerKilometer => _value/1e6, + VolumePerLengthUnit.LiterPerMeter => _value/1000, + VolumePerLengthUnit.LiterPerMillimeter => _value, + VolumePerLengthUnit.OilBarrelPerFoot => _value/1.91713408, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(VolumePerLengthUnit unit) @@ -218,18 +217,17 @@ private double GetValueAs(VolumePerLengthUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case VolumePerLengthUnit.CubicMeterPerMeter: return baseUnitValue; - case VolumePerLengthUnit.CubicYardPerFoot: return baseUnitValue/2.50838208; - case VolumePerLengthUnit.CubicYardPerUsSurveyFoot: return baseUnitValue/2.50837706323584; - case VolumePerLengthUnit.LiterPerKilometer: return baseUnitValue*1e6; - case VolumePerLengthUnit.LiterPerMeter: return baseUnitValue*1000; - case VolumePerLengthUnit.LiterPerMillimeter: return baseUnitValue; - case VolumePerLengthUnit.OilBarrelPerFoot: return baseUnitValue*1.91713408; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + VolumePerLengthUnit.CubicMeterPerMeter => baseUnitValue, + VolumePerLengthUnit.CubicYardPerFoot => baseUnitValue/2.50838208, + VolumePerLengthUnit.CubicYardPerUsSurveyFoot => baseUnitValue/2.50837706323584, + VolumePerLengthUnit.LiterPerKilometer => baseUnitValue*1e6, + VolumePerLengthUnit.LiterPerMeter => baseUnitValue*1000, + VolumePerLengthUnit.LiterPerMillimeter => baseUnitValue, + VolumePerLengthUnit.OilBarrelPerFoot => baseUnitValue*1.91713408, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index cb07e294f6..1114177bff 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -222,20 +222,19 @@ public VolumetricHeatCapacity ToUnit(VolumetricHeatCapacityUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit: return _value / 1.4910660e-5; - case VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius: return _value / 2.388459e-7; - case VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius: return _value; - case VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin: return _value; - case VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius: return (_value / 2.388459e-7) * 1e3d; - case VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius: return (_value) * 1e3d; - case VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin: return (_value) * 1e3d; - case VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius: return (_value) * 1e6d; - case VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin: return (_value) * 1e6d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit => _value / 1.4910660e-5, + VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius => _value / 2.388459e-7, + VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius => _value, + VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin => _value, + VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius => (_value / 2.388459e-7) * 1e3d, + VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius => (_value) * 1e3d, + VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin => (_value) * 1e3d, + VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius => (_value) * 1e6d, + VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin => (_value) * 1e6d, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(VolumetricHeatCapacityUnit unit) @@ -245,20 +244,19 @@ private double GetValueAs(VolumetricHeatCapacityUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit: return baseUnitValue * 1.4910660e-5; - case VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius: return baseUnitValue * 2.388459e-7; - case VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius: return baseUnitValue; - case VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin: return baseUnitValue; - case VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius: return (baseUnitValue * 2.388459e-7) / 1e3d; - case VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius: return (baseUnitValue) / 1e3d; - case VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin: return (baseUnitValue) / 1e3d; - case VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius: return (baseUnitValue) / 1e6d; - case VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin: return (baseUnitValue) / 1e6d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit => baseUnitValue * 1.4910660e-5, + VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius => baseUnitValue * 2.388459e-7, + VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius => baseUnitValue, + VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin => baseUnitValue, + VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius => (baseUnitValue * 2.388459e-7) / 1e3d, + VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius => (baseUnitValue) / 1e3d, + VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin => (baseUnitValue) / 1e3d, + VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius => (baseUnitValue) / 1e6d, + VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin => (baseUnitValue) / 1e6d, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 942eda081c..79d3852f97 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -186,17 +186,16 @@ public WarpingMomentOfInertia ToUnit(WarpingMomentOfInertiaUnit unit) /// The value in the base unit representation. private double GetValueInBaseUnit() { - switch(Unit) + return Unit switch { - case WarpingMomentOfInertiaUnit.CentimeterToTheSixth: return _value/1e12; - case WarpingMomentOfInertiaUnit.DecimeterToTheSixth: return _value/1e6; - case WarpingMomentOfInertiaUnit.FootToTheSixth: return _value*Math.Pow(0.3048, 6); - case WarpingMomentOfInertiaUnit.InchToTheSixth: return _value*Math.Pow(2.54e-2, 6); - case WarpingMomentOfInertiaUnit.MeterToTheSixth: return _value; - case WarpingMomentOfInertiaUnit.MillimeterToTheSixth: return _value/1e18; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } + WarpingMomentOfInertiaUnit.CentimeterToTheSixth => _value/1e12, + WarpingMomentOfInertiaUnit.DecimeterToTheSixth => _value/1e6, + WarpingMomentOfInertiaUnit.FootToTheSixth => _value*Math.Pow(0.3048, 6), + WarpingMomentOfInertiaUnit.InchToTheSixth => _value*Math.Pow(2.54e-2, 6), + WarpingMomentOfInertiaUnit.MeterToTheSixth => _value, + WarpingMomentOfInertiaUnit.MillimeterToTheSixth => _value/1e18, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; } private double GetValueAs(WarpingMomentOfInertiaUnit unit) @@ -206,17 +205,16 @@ private double GetValueAs(WarpingMomentOfInertiaUnit unit) var baseUnitValue = GetValueInBaseUnit(); - switch(unit) + return unit switch { - case WarpingMomentOfInertiaUnit.CentimeterToTheSixth: return baseUnitValue*1e12; - case WarpingMomentOfInertiaUnit.DecimeterToTheSixth: return baseUnitValue*1e6; - case WarpingMomentOfInertiaUnit.FootToTheSixth: return baseUnitValue/Math.Pow(0.3048, 6); - case WarpingMomentOfInertiaUnit.InchToTheSixth: return baseUnitValue/Math.Pow(2.54e-2, 6); - case WarpingMomentOfInertiaUnit.MeterToTheSixth: return baseUnitValue; - case WarpingMomentOfInertiaUnit.MillimeterToTheSixth: return baseUnitValue*1e18; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } + WarpingMomentOfInertiaUnit.CentimeterToTheSixth => baseUnitValue*1e12, + WarpingMomentOfInertiaUnit.DecimeterToTheSixth => baseUnitValue*1e6, + WarpingMomentOfInertiaUnit.FootToTheSixth => baseUnitValue/Math.Pow(0.3048, 6), + WarpingMomentOfInertiaUnit.InchToTheSixth => baseUnitValue/Math.Pow(2.54e-2, 6), + WarpingMomentOfInertiaUnit.MeterToTheSixth => baseUnitValue, + WarpingMomentOfInertiaUnit.MillimeterToTheSixth => baseUnitValue*1e18, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; } #endregion diff --git a/UnitsNet.Tests/QuantityTest.cs b/UnitsNet.Tests/QuantityTest.cs index d25421a990..5085e531ac 100644 --- a/UnitsNet.Tests/QuantityTest.cs +++ b/UnitsNet.Tests/QuantityTest.cs @@ -21,6 +21,7 @@ public class QuantityTest [InlineData(double.NegativeInfinity)] public void From_GivenNaNOrInfinity_ThrowsArgumentException(double value) { + Quantity.Infos.Select(qi=>qi.ValueType); Assert.Throws(() => Quantity.From(value, LengthUnit.Centimeter)); } diff --git a/UnitsNet/GeneratedCode/Quantity.g.cs b/UnitsNet/GeneratedCode/Quantity.g.cs index 237b644386..4e06eecf12 100644 --- a/UnitsNet/GeneratedCode/Quantity.g.cs +++ b/UnitsNet/GeneratedCode/Quantity.g.cs @@ -161,235 +161,122 @@ public static partial class Quantity [Obsolete("QuantityType will be removed. Use FromQuantityInfo(QuantityInfo, QuantityValue) instead.")] public static IQuantity FromQuantityType(QuantityType quantityType, QuantityValue value) { - switch(quantityType) + return quantityType switch { - case QuantityType.Acceleration: - return Acceleration.From(value, Acceleration.BaseUnit); - case QuantityType.AmountOfSubstance: - return AmountOfSubstance.From(value, AmountOfSubstance.BaseUnit); - case QuantityType.AmplitudeRatio: - return AmplitudeRatio.From(value, AmplitudeRatio.BaseUnit); - case QuantityType.Angle: - return Angle.From(value, Angle.BaseUnit); - case QuantityType.ApparentEnergy: - return ApparentEnergy.From(value, ApparentEnergy.BaseUnit); - case QuantityType.ApparentPower: - return ApparentPower.From(value, ApparentPower.BaseUnit); - case QuantityType.Area: - return Area.From(value, Area.BaseUnit); - case QuantityType.AreaDensity: - return AreaDensity.From(value, AreaDensity.BaseUnit); - case QuantityType.AreaMomentOfInertia: - return AreaMomentOfInertia.From(value, AreaMomentOfInertia.BaseUnit); - case QuantityType.BitRate: - return BitRate.From(value, BitRate.BaseUnit); - case QuantityType.BrakeSpecificFuelConsumption: - return BrakeSpecificFuelConsumption.From(value, BrakeSpecificFuelConsumption.BaseUnit); - case QuantityType.Capacitance: - return Capacitance.From(value, Capacitance.BaseUnit); - case QuantityType.CoefficientOfThermalExpansion: - return CoefficientOfThermalExpansion.From(value, CoefficientOfThermalExpansion.BaseUnit); - case QuantityType.Density: - return Density.From(value, Density.BaseUnit); - case QuantityType.Duration: - return Duration.From(value, Duration.BaseUnit); - case QuantityType.DynamicViscosity: - return DynamicViscosity.From(value, DynamicViscosity.BaseUnit); - case QuantityType.ElectricAdmittance: - return ElectricAdmittance.From(value, ElectricAdmittance.BaseUnit); - case QuantityType.ElectricCharge: - return ElectricCharge.From(value, ElectricCharge.BaseUnit); - case QuantityType.ElectricChargeDensity: - return ElectricChargeDensity.From(value, ElectricChargeDensity.BaseUnit); - case QuantityType.ElectricConductance: - return ElectricConductance.From(value, ElectricConductance.BaseUnit); - case QuantityType.ElectricConductivity: - return ElectricConductivity.From(value, ElectricConductivity.BaseUnit); - case QuantityType.ElectricCurrent: - return ElectricCurrent.From(value, ElectricCurrent.BaseUnit); - case QuantityType.ElectricCurrentDensity: - return ElectricCurrentDensity.From(value, ElectricCurrentDensity.BaseUnit); - case QuantityType.ElectricCurrentGradient: - return ElectricCurrentGradient.From(value, ElectricCurrentGradient.BaseUnit); - case QuantityType.ElectricField: - return ElectricField.From(value, ElectricField.BaseUnit); - case QuantityType.ElectricInductance: - return ElectricInductance.From(value, ElectricInductance.BaseUnit); - case QuantityType.ElectricPotential: - return ElectricPotential.From(value, ElectricPotential.BaseUnit); - case QuantityType.ElectricPotentialAc: - return ElectricPotentialAc.From(value, ElectricPotentialAc.BaseUnit); - case QuantityType.ElectricPotentialChangeRate: - return ElectricPotentialChangeRate.From(value, ElectricPotentialChangeRate.BaseUnit); - case QuantityType.ElectricPotentialDc: - return ElectricPotentialDc.From(value, ElectricPotentialDc.BaseUnit); - case QuantityType.ElectricResistance: - return ElectricResistance.From(value, ElectricResistance.BaseUnit); - case QuantityType.ElectricResistivity: - return ElectricResistivity.From(value, ElectricResistivity.BaseUnit); - case QuantityType.ElectricSurfaceChargeDensity: - return ElectricSurfaceChargeDensity.From(value, ElectricSurfaceChargeDensity.BaseUnit); - case QuantityType.Energy: - return Energy.From(value, Energy.BaseUnit); - case QuantityType.Entropy: - return Entropy.From(value, Entropy.BaseUnit); - case QuantityType.Force: - return Force.From(value, Force.BaseUnit); - case QuantityType.ForceChangeRate: - return ForceChangeRate.From(value, ForceChangeRate.BaseUnit); - case QuantityType.ForcePerLength: - return ForcePerLength.From(value, ForcePerLength.BaseUnit); - case QuantityType.Frequency: - return Frequency.From(value, Frequency.BaseUnit); - case QuantityType.FuelEfficiency: - return FuelEfficiency.From(value, FuelEfficiency.BaseUnit); - case QuantityType.HeatFlux: - return HeatFlux.From(value, HeatFlux.BaseUnit); - case QuantityType.HeatTransferCoefficient: - return HeatTransferCoefficient.From(value, HeatTransferCoefficient.BaseUnit); - case QuantityType.Illuminance: - return Illuminance.From(value, Illuminance.BaseUnit); - case QuantityType.Information: - return Information.From(value, Information.BaseUnit); - case QuantityType.Irradiance: - return Irradiance.From(value, Irradiance.BaseUnit); - case QuantityType.Irradiation: - return Irradiation.From(value, Irradiation.BaseUnit); - case QuantityType.KinematicViscosity: - return KinematicViscosity.From(value, KinematicViscosity.BaseUnit); - case QuantityType.LapseRate: - return LapseRate.From(value, LapseRate.BaseUnit); - case QuantityType.Length: - return Length.From(value, Length.BaseUnit); - case QuantityType.Level: - return Level.From(value, Level.BaseUnit); - case QuantityType.LinearDensity: - return LinearDensity.From(value, LinearDensity.BaseUnit); - case QuantityType.LinearPowerDensity: - return LinearPowerDensity.From(value, LinearPowerDensity.BaseUnit); - case QuantityType.Luminosity: - return Luminosity.From(value, Luminosity.BaseUnit); - case QuantityType.LuminousFlux: - return LuminousFlux.From(value, LuminousFlux.BaseUnit); - case QuantityType.LuminousIntensity: - return LuminousIntensity.From(value, LuminousIntensity.BaseUnit); - case QuantityType.MagneticField: - return MagneticField.From(value, MagneticField.BaseUnit); - case QuantityType.MagneticFlux: - return MagneticFlux.From(value, MagneticFlux.BaseUnit); - case QuantityType.Magnetization: - return Magnetization.From(value, Magnetization.BaseUnit); - case QuantityType.Mass: - return Mass.From(value, Mass.BaseUnit); - case QuantityType.MassConcentration: - return MassConcentration.From(value, MassConcentration.BaseUnit); - case QuantityType.MassFlow: - return MassFlow.From(value, MassFlow.BaseUnit); - case QuantityType.MassFlux: - return MassFlux.From(value, MassFlux.BaseUnit); - case QuantityType.MassFraction: - return MassFraction.From(value, MassFraction.BaseUnit); - case QuantityType.MassMomentOfInertia: - return MassMomentOfInertia.From(value, MassMomentOfInertia.BaseUnit); - case QuantityType.MolarEnergy: - return MolarEnergy.From(value, MolarEnergy.BaseUnit); - case QuantityType.MolarEntropy: - return MolarEntropy.From(value, MolarEntropy.BaseUnit); - case QuantityType.Molarity: - return Molarity.From(value, Molarity.BaseUnit); - case QuantityType.MolarMass: - return MolarMass.From(value, MolarMass.BaseUnit); - case QuantityType.Permeability: - return Permeability.From(value, Permeability.BaseUnit); - case QuantityType.Permittivity: - return Permittivity.From(value, Permittivity.BaseUnit); - case QuantityType.Power: - return Power.From(value, Power.BaseUnit); - case QuantityType.PowerDensity: - return PowerDensity.From(value, PowerDensity.BaseUnit); - case QuantityType.PowerRatio: - return PowerRatio.From(value, PowerRatio.BaseUnit); - case QuantityType.Pressure: - return Pressure.From(value, Pressure.BaseUnit); - case QuantityType.PressureChangeRate: - return PressureChangeRate.From(value, PressureChangeRate.BaseUnit); - case QuantityType.Ratio: - return Ratio.From(value, Ratio.BaseUnit); - case QuantityType.RatioChangeRate: - return RatioChangeRate.From(value, RatioChangeRate.BaseUnit); - case QuantityType.ReactiveEnergy: - return ReactiveEnergy.From(value, ReactiveEnergy.BaseUnit); - case QuantityType.ReactivePower: - return ReactivePower.From(value, ReactivePower.BaseUnit); - case QuantityType.ReciprocalArea: - return ReciprocalArea.From(value, ReciprocalArea.BaseUnit); - case QuantityType.ReciprocalLength: - return ReciprocalLength.From(value, ReciprocalLength.BaseUnit); - case QuantityType.RelativeHumidity: - return RelativeHumidity.From(value, RelativeHumidity.BaseUnit); - case QuantityType.RotationalAcceleration: - return RotationalAcceleration.From(value, RotationalAcceleration.BaseUnit); - case QuantityType.RotationalSpeed: - return RotationalSpeed.From(value, RotationalSpeed.BaseUnit); - case QuantityType.RotationalStiffness: - return RotationalStiffness.From(value, RotationalStiffness.BaseUnit); - case QuantityType.RotationalStiffnessPerLength: - return RotationalStiffnessPerLength.From(value, RotationalStiffnessPerLength.BaseUnit); - case QuantityType.Scalar: - return Scalar.From(value, Scalar.BaseUnit); - case QuantityType.SolidAngle: - return SolidAngle.From(value, SolidAngle.BaseUnit); - case QuantityType.SpecificEnergy: - return SpecificEnergy.From(value, SpecificEnergy.BaseUnit); - case QuantityType.SpecificEntropy: - return SpecificEntropy.From(value, SpecificEntropy.BaseUnit); - case QuantityType.SpecificFuelConsumption: - return SpecificFuelConsumption.From(value, SpecificFuelConsumption.BaseUnit); - case QuantityType.SpecificVolume: - return SpecificVolume.From(value, SpecificVolume.BaseUnit); - case QuantityType.SpecificWeight: - return SpecificWeight.From(value, SpecificWeight.BaseUnit); - case QuantityType.Speed: - return Speed.From(value, Speed.BaseUnit); - case QuantityType.StandardVolumeFlow: - return StandardVolumeFlow.From(value, StandardVolumeFlow.BaseUnit); - case QuantityType.Temperature: - return Temperature.From(value, Temperature.BaseUnit); - case QuantityType.TemperatureChangeRate: - return TemperatureChangeRate.From(value, TemperatureChangeRate.BaseUnit); - case QuantityType.TemperatureDelta: - return TemperatureDelta.From(value, TemperatureDelta.BaseUnit); - case QuantityType.TemperatureGradient: - return TemperatureGradient.From(value, TemperatureGradient.BaseUnit); - case QuantityType.ThermalConductivity: - return ThermalConductivity.From(value, ThermalConductivity.BaseUnit); - case QuantityType.ThermalResistance: - return ThermalResistance.From(value, ThermalResistance.BaseUnit); - case QuantityType.Torque: - return Torque.From(value, Torque.BaseUnit); - case QuantityType.TorquePerLength: - return TorquePerLength.From(value, TorquePerLength.BaseUnit); - case QuantityType.Turbidity: - return Turbidity.From(value, Turbidity.BaseUnit); - case QuantityType.VitaminA: - return VitaminA.From(value, VitaminA.BaseUnit); - case QuantityType.Volume: - return Volume.From(value, Volume.BaseUnit); - case QuantityType.VolumeConcentration: - return VolumeConcentration.From(value, VolumeConcentration.BaseUnit); - case QuantityType.VolumeFlow: - return VolumeFlow.From(value, VolumeFlow.BaseUnit); - case QuantityType.VolumeFlowPerArea: - return VolumeFlowPerArea.From(value, VolumeFlowPerArea.BaseUnit); - case QuantityType.VolumePerLength: - return VolumePerLength.From(value, VolumePerLength.BaseUnit); - case QuantityType.VolumetricHeatCapacity: - return VolumetricHeatCapacity.From(value, VolumetricHeatCapacity.BaseUnit); - case QuantityType.WarpingMomentOfInertia: - return WarpingMomentOfInertia.From(value, WarpingMomentOfInertia.BaseUnit); - default: - throw new ArgumentException($"{quantityType} is not a supported quantity type."); - } + QuantityType.Acceleration => Acceleration.From(value, Acceleration.BaseUnit), + QuantityType.AmountOfSubstance => AmountOfSubstance.From(value, AmountOfSubstance.BaseUnit), + QuantityType.AmplitudeRatio => AmplitudeRatio.From(value, AmplitudeRatio.BaseUnit), + QuantityType.Angle => Angle.From(value, Angle.BaseUnit), + QuantityType.ApparentEnergy => ApparentEnergy.From(value, ApparentEnergy.BaseUnit), + QuantityType.ApparentPower => ApparentPower.From(value, ApparentPower.BaseUnit), + QuantityType.Area => Area.From(value, Area.BaseUnit), + QuantityType.AreaDensity => AreaDensity.From(value, AreaDensity.BaseUnit), + QuantityType.AreaMomentOfInertia => AreaMomentOfInertia.From(value, AreaMomentOfInertia.BaseUnit), + QuantityType.BitRate => BitRate.From(value, BitRate.BaseUnit), + QuantityType.BrakeSpecificFuelConsumption => BrakeSpecificFuelConsumption.From(value, BrakeSpecificFuelConsumption.BaseUnit), + QuantityType.Capacitance => Capacitance.From(value, Capacitance.BaseUnit), + QuantityType.CoefficientOfThermalExpansion => CoefficientOfThermalExpansion.From(value, CoefficientOfThermalExpansion.BaseUnit), + QuantityType.Density => Density.From(value, Density.BaseUnit), + QuantityType.Duration => Duration.From(value, Duration.BaseUnit), + QuantityType.DynamicViscosity => DynamicViscosity.From(value, DynamicViscosity.BaseUnit), + QuantityType.ElectricAdmittance => ElectricAdmittance.From(value, ElectricAdmittance.BaseUnit), + QuantityType.ElectricCharge => ElectricCharge.From(value, ElectricCharge.BaseUnit), + QuantityType.ElectricChargeDensity => ElectricChargeDensity.From(value, ElectricChargeDensity.BaseUnit), + QuantityType.ElectricConductance => ElectricConductance.From(value, ElectricConductance.BaseUnit), + QuantityType.ElectricConductivity => ElectricConductivity.From(value, ElectricConductivity.BaseUnit), + QuantityType.ElectricCurrent => ElectricCurrent.From(value, ElectricCurrent.BaseUnit), + QuantityType.ElectricCurrentDensity => ElectricCurrentDensity.From(value, ElectricCurrentDensity.BaseUnit), + QuantityType.ElectricCurrentGradient => ElectricCurrentGradient.From(value, ElectricCurrentGradient.BaseUnit), + QuantityType.ElectricField => ElectricField.From(value, ElectricField.BaseUnit), + QuantityType.ElectricInductance => ElectricInductance.From(value, ElectricInductance.BaseUnit), + QuantityType.ElectricPotential => ElectricPotential.From(value, ElectricPotential.BaseUnit), + QuantityType.ElectricPotentialAc => ElectricPotentialAc.From(value, ElectricPotentialAc.BaseUnit), + QuantityType.ElectricPotentialChangeRate => ElectricPotentialChangeRate.From(value, ElectricPotentialChangeRate.BaseUnit), + QuantityType.ElectricPotentialDc => ElectricPotentialDc.From(value, ElectricPotentialDc.BaseUnit), + QuantityType.ElectricResistance => ElectricResistance.From(value, ElectricResistance.BaseUnit), + QuantityType.ElectricResistivity => ElectricResistivity.From(value, ElectricResistivity.BaseUnit), + QuantityType.ElectricSurfaceChargeDensity => ElectricSurfaceChargeDensity.From(value, ElectricSurfaceChargeDensity.BaseUnit), + QuantityType.Energy => Energy.From(value, Energy.BaseUnit), + QuantityType.Entropy => Entropy.From(value, Entropy.BaseUnit), + QuantityType.Force => Force.From(value, Force.BaseUnit), + QuantityType.ForceChangeRate => ForceChangeRate.From(value, ForceChangeRate.BaseUnit), + QuantityType.ForcePerLength => ForcePerLength.From(value, ForcePerLength.BaseUnit), + QuantityType.Frequency => Frequency.From(value, Frequency.BaseUnit), + QuantityType.FuelEfficiency => FuelEfficiency.From(value, FuelEfficiency.BaseUnit), + QuantityType.HeatFlux => HeatFlux.From(value, HeatFlux.BaseUnit), + QuantityType.HeatTransferCoefficient => HeatTransferCoefficient.From(value, HeatTransferCoefficient.BaseUnit), + QuantityType.Illuminance => Illuminance.From(value, Illuminance.BaseUnit), + QuantityType.Information => Information.From(value, Information.BaseUnit), + QuantityType.Irradiance => Irradiance.From(value, Irradiance.BaseUnit), + QuantityType.Irradiation => Irradiation.From(value, Irradiation.BaseUnit), + QuantityType.KinematicViscosity => KinematicViscosity.From(value, KinematicViscosity.BaseUnit), + QuantityType.LapseRate => LapseRate.From(value, LapseRate.BaseUnit), + QuantityType.Length => Length.From(value, Length.BaseUnit), + QuantityType.Level => Level.From(value, Level.BaseUnit), + QuantityType.LinearDensity => LinearDensity.From(value, LinearDensity.BaseUnit), + QuantityType.LinearPowerDensity => LinearPowerDensity.From(value, LinearPowerDensity.BaseUnit), + QuantityType.Luminosity => Luminosity.From(value, Luminosity.BaseUnit), + QuantityType.LuminousFlux => LuminousFlux.From(value, LuminousFlux.BaseUnit), + QuantityType.LuminousIntensity => LuminousIntensity.From(value, LuminousIntensity.BaseUnit), + QuantityType.MagneticField => MagneticField.From(value, MagneticField.BaseUnit), + QuantityType.MagneticFlux => MagneticFlux.From(value, MagneticFlux.BaseUnit), + QuantityType.Magnetization => Magnetization.From(value, Magnetization.BaseUnit), + QuantityType.Mass => Mass.From(value, Mass.BaseUnit), + QuantityType.MassConcentration => MassConcentration.From(value, MassConcentration.BaseUnit), + QuantityType.MassFlow => MassFlow.From(value, MassFlow.BaseUnit), + QuantityType.MassFlux => MassFlux.From(value, MassFlux.BaseUnit), + QuantityType.MassFraction => MassFraction.From(value, MassFraction.BaseUnit), + QuantityType.MassMomentOfInertia => MassMomentOfInertia.From(value, MassMomentOfInertia.BaseUnit), + QuantityType.MolarEnergy => MolarEnergy.From(value, MolarEnergy.BaseUnit), + QuantityType.MolarEntropy => MolarEntropy.From(value, MolarEntropy.BaseUnit), + QuantityType.Molarity => Molarity.From(value, Molarity.BaseUnit), + QuantityType.MolarMass => MolarMass.From(value, MolarMass.BaseUnit), + QuantityType.Permeability => Permeability.From(value, Permeability.BaseUnit), + QuantityType.Permittivity => Permittivity.From(value, Permittivity.BaseUnit), + QuantityType.Power => Power.From(value, Power.BaseUnit), + QuantityType.PowerDensity => PowerDensity.From(value, PowerDensity.BaseUnit), + QuantityType.PowerRatio => PowerRatio.From(value, PowerRatio.BaseUnit), + QuantityType.Pressure => Pressure.From(value, Pressure.BaseUnit), + QuantityType.PressureChangeRate => PressureChangeRate.From(value, PressureChangeRate.BaseUnit), + QuantityType.Ratio => Ratio.From(value, Ratio.BaseUnit), + QuantityType.RatioChangeRate => RatioChangeRate.From(value, RatioChangeRate.BaseUnit), + QuantityType.ReactiveEnergy => ReactiveEnergy.From(value, ReactiveEnergy.BaseUnit), + QuantityType.ReactivePower => ReactivePower.From(value, ReactivePower.BaseUnit), + QuantityType.ReciprocalArea => ReciprocalArea.From(value, ReciprocalArea.BaseUnit), + QuantityType.ReciprocalLength => ReciprocalLength.From(value, ReciprocalLength.BaseUnit), + QuantityType.RelativeHumidity => RelativeHumidity.From(value, RelativeHumidity.BaseUnit), + QuantityType.RotationalAcceleration => RotationalAcceleration.From(value, RotationalAcceleration.BaseUnit), + QuantityType.RotationalSpeed => RotationalSpeed.From(value, RotationalSpeed.BaseUnit), + QuantityType.RotationalStiffness => RotationalStiffness.From(value, RotationalStiffness.BaseUnit), + QuantityType.RotationalStiffnessPerLength => RotationalStiffnessPerLength.From(value, RotationalStiffnessPerLength.BaseUnit), + QuantityType.Scalar => Scalar.From(value, Scalar.BaseUnit), + QuantityType.SolidAngle => SolidAngle.From(value, SolidAngle.BaseUnit), + QuantityType.SpecificEnergy => SpecificEnergy.From(value, SpecificEnergy.BaseUnit), + QuantityType.SpecificEntropy => SpecificEntropy.From(value, SpecificEntropy.BaseUnit), + QuantityType.SpecificFuelConsumption => SpecificFuelConsumption.From(value, SpecificFuelConsumption.BaseUnit), + QuantityType.SpecificVolume => SpecificVolume.From(value, SpecificVolume.BaseUnit), + QuantityType.SpecificWeight => SpecificWeight.From(value, SpecificWeight.BaseUnit), + QuantityType.Speed => Speed.From(value, Speed.BaseUnit), + QuantityType.StandardVolumeFlow => StandardVolumeFlow.From(value, StandardVolumeFlow.BaseUnit), + QuantityType.Temperature => Temperature.From(value, Temperature.BaseUnit), + QuantityType.TemperatureChangeRate => TemperatureChangeRate.From(value, TemperatureChangeRate.BaseUnit), + QuantityType.TemperatureDelta => TemperatureDelta.From(value, TemperatureDelta.BaseUnit), + QuantityType.TemperatureGradient => TemperatureGradient.From(value, TemperatureGradient.BaseUnit), + QuantityType.ThermalConductivity => ThermalConductivity.From(value, ThermalConductivity.BaseUnit), + QuantityType.ThermalResistance => ThermalResistance.From(value, ThermalResistance.BaseUnit), + QuantityType.Torque => Torque.From(value, Torque.BaseUnit), + QuantityType.TorquePerLength => TorquePerLength.From(value, TorquePerLength.BaseUnit), + QuantityType.Turbidity => Turbidity.From(value, Turbidity.BaseUnit), + QuantityType.VitaminA => VitaminA.From(value, VitaminA.BaseUnit), + QuantityType.Volume => Volume.From(value, Volume.BaseUnit), + QuantityType.VolumeConcentration => VolumeConcentration.From(value, VolumeConcentration.BaseUnit), + QuantityType.VolumeFlow => VolumeFlow.From(value, VolumeFlow.BaseUnit), + QuantityType.VolumeFlowPerArea => VolumeFlowPerArea.From(value, VolumeFlowPerArea.BaseUnit), + QuantityType.VolumePerLength => VolumePerLength.From(value, VolumePerLength.BaseUnit), + QuantityType.VolumetricHeatCapacity => VolumetricHeatCapacity.From(value, VolumetricHeatCapacity.BaseUnit), + QuantityType.WarpingMomentOfInertia => WarpingMomentOfInertia.From(value, WarpingMomentOfInertia.BaseUnit), + _ => throw new ArgumentException($"{quantityType} is not a supported quantity type.") + }; } /// @@ -400,235 +287,122 @@ public static IQuantity FromQuantityType(QuantityType quantityType, QuantityValu /// The created quantity. public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, QuantityValue value) { - switch(quantityInfo.Name) + return quantityInfo.Name switch { - case "Acceleration": - return Acceleration.From(value, Acceleration.BaseUnit); - case "AmountOfSubstance": - return AmountOfSubstance.From(value, AmountOfSubstance.BaseUnit); - case "AmplitudeRatio": - return AmplitudeRatio.From(value, AmplitudeRatio.BaseUnit); - case "Angle": - return Angle.From(value, Angle.BaseUnit); - case "ApparentEnergy": - return ApparentEnergy.From(value, ApparentEnergy.BaseUnit); - case "ApparentPower": - return ApparentPower.From(value, ApparentPower.BaseUnit); - case "Area": - return Area.From(value, Area.BaseUnit); - case "AreaDensity": - return AreaDensity.From(value, AreaDensity.BaseUnit); - case "AreaMomentOfInertia": - return AreaMomentOfInertia.From(value, AreaMomentOfInertia.BaseUnit); - case "BitRate": - return BitRate.From(value, BitRate.BaseUnit); - case "BrakeSpecificFuelConsumption": - return BrakeSpecificFuelConsumption.From(value, BrakeSpecificFuelConsumption.BaseUnit); - case "Capacitance": - return Capacitance.From(value, Capacitance.BaseUnit); - case "CoefficientOfThermalExpansion": - return CoefficientOfThermalExpansion.From(value, CoefficientOfThermalExpansion.BaseUnit); - case "Density": - return Density.From(value, Density.BaseUnit); - case "Duration": - return Duration.From(value, Duration.BaseUnit); - case "DynamicViscosity": - return DynamicViscosity.From(value, DynamicViscosity.BaseUnit); - case "ElectricAdmittance": - return ElectricAdmittance.From(value, ElectricAdmittance.BaseUnit); - case "ElectricCharge": - return ElectricCharge.From(value, ElectricCharge.BaseUnit); - case "ElectricChargeDensity": - return ElectricChargeDensity.From(value, ElectricChargeDensity.BaseUnit); - case "ElectricConductance": - return ElectricConductance.From(value, ElectricConductance.BaseUnit); - case "ElectricConductivity": - return ElectricConductivity.From(value, ElectricConductivity.BaseUnit); - case "ElectricCurrent": - return ElectricCurrent.From(value, ElectricCurrent.BaseUnit); - case "ElectricCurrentDensity": - return ElectricCurrentDensity.From(value, ElectricCurrentDensity.BaseUnit); - case "ElectricCurrentGradient": - return ElectricCurrentGradient.From(value, ElectricCurrentGradient.BaseUnit); - case "ElectricField": - return ElectricField.From(value, ElectricField.BaseUnit); - case "ElectricInductance": - return ElectricInductance.From(value, ElectricInductance.BaseUnit); - case "ElectricPotential": - return ElectricPotential.From(value, ElectricPotential.BaseUnit); - case "ElectricPotentialAc": - return ElectricPotentialAc.From(value, ElectricPotentialAc.BaseUnit); - case "ElectricPotentialChangeRate": - return ElectricPotentialChangeRate.From(value, ElectricPotentialChangeRate.BaseUnit); - case "ElectricPotentialDc": - return ElectricPotentialDc.From(value, ElectricPotentialDc.BaseUnit); - case "ElectricResistance": - return ElectricResistance.From(value, ElectricResistance.BaseUnit); - case "ElectricResistivity": - return ElectricResistivity.From(value, ElectricResistivity.BaseUnit); - case "ElectricSurfaceChargeDensity": - return ElectricSurfaceChargeDensity.From(value, ElectricSurfaceChargeDensity.BaseUnit); - case "Energy": - return Energy.From(value, Energy.BaseUnit); - case "Entropy": - return Entropy.From(value, Entropy.BaseUnit); - case "Force": - return Force.From(value, Force.BaseUnit); - case "ForceChangeRate": - return ForceChangeRate.From(value, ForceChangeRate.BaseUnit); - case "ForcePerLength": - return ForcePerLength.From(value, ForcePerLength.BaseUnit); - case "Frequency": - return Frequency.From(value, Frequency.BaseUnit); - case "FuelEfficiency": - return FuelEfficiency.From(value, FuelEfficiency.BaseUnit); - case "HeatFlux": - return HeatFlux.From(value, HeatFlux.BaseUnit); - case "HeatTransferCoefficient": - return HeatTransferCoefficient.From(value, HeatTransferCoefficient.BaseUnit); - case "Illuminance": - return Illuminance.From(value, Illuminance.BaseUnit); - case "Information": - return Information.From(value, Information.BaseUnit); - case "Irradiance": - return Irradiance.From(value, Irradiance.BaseUnit); - case "Irradiation": - return Irradiation.From(value, Irradiation.BaseUnit); - case "KinematicViscosity": - return KinematicViscosity.From(value, KinematicViscosity.BaseUnit); - case "LapseRate": - return LapseRate.From(value, LapseRate.BaseUnit); - case "Length": - return Length.From(value, Length.BaseUnit); - case "Level": - return Level.From(value, Level.BaseUnit); - case "LinearDensity": - return LinearDensity.From(value, LinearDensity.BaseUnit); - case "LinearPowerDensity": - return LinearPowerDensity.From(value, LinearPowerDensity.BaseUnit); - case "Luminosity": - return Luminosity.From(value, Luminosity.BaseUnit); - case "LuminousFlux": - return LuminousFlux.From(value, LuminousFlux.BaseUnit); - case "LuminousIntensity": - return LuminousIntensity.From(value, LuminousIntensity.BaseUnit); - case "MagneticField": - return MagneticField.From(value, MagneticField.BaseUnit); - case "MagneticFlux": - return MagneticFlux.From(value, MagneticFlux.BaseUnit); - case "Magnetization": - return Magnetization.From(value, Magnetization.BaseUnit); - case "Mass": - return Mass.From(value, Mass.BaseUnit); - case "MassConcentration": - return MassConcentration.From(value, MassConcentration.BaseUnit); - case "MassFlow": - return MassFlow.From(value, MassFlow.BaseUnit); - case "MassFlux": - return MassFlux.From(value, MassFlux.BaseUnit); - case "MassFraction": - return MassFraction.From(value, MassFraction.BaseUnit); - case "MassMomentOfInertia": - return MassMomentOfInertia.From(value, MassMomentOfInertia.BaseUnit); - case "MolarEnergy": - return MolarEnergy.From(value, MolarEnergy.BaseUnit); - case "MolarEntropy": - return MolarEntropy.From(value, MolarEntropy.BaseUnit); - case "Molarity": - return Molarity.From(value, Molarity.BaseUnit); - case "MolarMass": - return MolarMass.From(value, MolarMass.BaseUnit); - case "Permeability": - return Permeability.From(value, Permeability.BaseUnit); - case "Permittivity": - return Permittivity.From(value, Permittivity.BaseUnit); - case "Power": - return Power.From(value, Power.BaseUnit); - case "PowerDensity": - return PowerDensity.From(value, PowerDensity.BaseUnit); - case "PowerRatio": - return PowerRatio.From(value, PowerRatio.BaseUnit); - case "Pressure": - return Pressure.From(value, Pressure.BaseUnit); - case "PressureChangeRate": - return PressureChangeRate.From(value, PressureChangeRate.BaseUnit); - case "Ratio": - return Ratio.From(value, Ratio.BaseUnit); - case "RatioChangeRate": - return RatioChangeRate.From(value, RatioChangeRate.BaseUnit); - case "ReactiveEnergy": - return ReactiveEnergy.From(value, ReactiveEnergy.BaseUnit); - case "ReactivePower": - return ReactivePower.From(value, ReactivePower.BaseUnit); - case "ReciprocalArea": - return ReciprocalArea.From(value, ReciprocalArea.BaseUnit); - case "ReciprocalLength": - return ReciprocalLength.From(value, ReciprocalLength.BaseUnit); - case "RelativeHumidity": - return RelativeHumidity.From(value, RelativeHumidity.BaseUnit); - case "RotationalAcceleration": - return RotationalAcceleration.From(value, RotationalAcceleration.BaseUnit); - case "RotationalSpeed": - return RotationalSpeed.From(value, RotationalSpeed.BaseUnit); - case "RotationalStiffness": - return RotationalStiffness.From(value, RotationalStiffness.BaseUnit); - case "RotationalStiffnessPerLength": - return RotationalStiffnessPerLength.From(value, RotationalStiffnessPerLength.BaseUnit); - case "Scalar": - return Scalar.From(value, Scalar.BaseUnit); - case "SolidAngle": - return SolidAngle.From(value, SolidAngle.BaseUnit); - case "SpecificEnergy": - return SpecificEnergy.From(value, SpecificEnergy.BaseUnit); - case "SpecificEntropy": - return SpecificEntropy.From(value, SpecificEntropy.BaseUnit); - case "SpecificFuelConsumption": - return SpecificFuelConsumption.From(value, SpecificFuelConsumption.BaseUnit); - case "SpecificVolume": - return SpecificVolume.From(value, SpecificVolume.BaseUnit); - case "SpecificWeight": - return SpecificWeight.From(value, SpecificWeight.BaseUnit); - case "Speed": - return Speed.From(value, Speed.BaseUnit); - case "StandardVolumeFlow": - return StandardVolumeFlow.From(value, StandardVolumeFlow.BaseUnit); - case "Temperature": - return Temperature.From(value, Temperature.BaseUnit); - case "TemperatureChangeRate": - return TemperatureChangeRate.From(value, TemperatureChangeRate.BaseUnit); - case "TemperatureDelta": - return TemperatureDelta.From(value, TemperatureDelta.BaseUnit); - case "TemperatureGradient": - return TemperatureGradient.From(value, TemperatureGradient.BaseUnit); - case "ThermalConductivity": - return ThermalConductivity.From(value, ThermalConductivity.BaseUnit); - case "ThermalResistance": - return ThermalResistance.From(value, ThermalResistance.BaseUnit); - case "Torque": - return Torque.From(value, Torque.BaseUnit); - case "TorquePerLength": - return TorquePerLength.From(value, TorquePerLength.BaseUnit); - case "Turbidity": - return Turbidity.From(value, Turbidity.BaseUnit); - case "VitaminA": - return VitaminA.From(value, VitaminA.BaseUnit); - case "Volume": - return Volume.From(value, Volume.BaseUnit); - case "VolumeConcentration": - return VolumeConcentration.From(value, VolumeConcentration.BaseUnit); - case "VolumeFlow": - return VolumeFlow.From(value, VolumeFlow.BaseUnit); - case "VolumeFlowPerArea": - return VolumeFlowPerArea.From(value, VolumeFlowPerArea.BaseUnit); - case "VolumePerLength": - return VolumePerLength.From(value, VolumePerLength.BaseUnit); - case "VolumetricHeatCapacity": - return VolumetricHeatCapacity.From(value, VolumetricHeatCapacity.BaseUnit); - case "WarpingMomentOfInertia": - return WarpingMomentOfInertia.From(value, WarpingMomentOfInertia.BaseUnit); - default: - throw new ArgumentException($"{quantityInfo.Name} is not a supported quantity."); - } + "Acceleration" => Acceleration.From(value, Acceleration.BaseUnit), + "AmountOfSubstance" => AmountOfSubstance.From(value, AmountOfSubstance.BaseUnit), + "AmplitudeRatio" => AmplitudeRatio.From(value, AmplitudeRatio.BaseUnit), + "Angle" => Angle.From(value, Angle.BaseUnit), + "ApparentEnergy" => ApparentEnergy.From(value, ApparentEnergy.BaseUnit), + "ApparentPower" => ApparentPower.From(value, ApparentPower.BaseUnit), + "Area" => Area.From(value, Area.BaseUnit), + "AreaDensity" => AreaDensity.From(value, AreaDensity.BaseUnit), + "AreaMomentOfInertia" => AreaMomentOfInertia.From(value, AreaMomentOfInertia.BaseUnit), + "BitRate" => BitRate.From(value, BitRate.BaseUnit), + "BrakeSpecificFuelConsumption" => BrakeSpecificFuelConsumption.From(value, BrakeSpecificFuelConsumption.BaseUnit), + "Capacitance" => Capacitance.From(value, Capacitance.BaseUnit), + "CoefficientOfThermalExpansion" => CoefficientOfThermalExpansion.From(value, CoefficientOfThermalExpansion.BaseUnit), + "Density" => Density.From(value, Density.BaseUnit), + "Duration" => Duration.From(value, Duration.BaseUnit), + "DynamicViscosity" => DynamicViscosity.From(value, DynamicViscosity.BaseUnit), + "ElectricAdmittance" => ElectricAdmittance.From(value, ElectricAdmittance.BaseUnit), + "ElectricCharge" => ElectricCharge.From(value, ElectricCharge.BaseUnit), + "ElectricChargeDensity" => ElectricChargeDensity.From(value, ElectricChargeDensity.BaseUnit), + "ElectricConductance" => ElectricConductance.From(value, ElectricConductance.BaseUnit), + "ElectricConductivity" => ElectricConductivity.From(value, ElectricConductivity.BaseUnit), + "ElectricCurrent" => ElectricCurrent.From(value, ElectricCurrent.BaseUnit), + "ElectricCurrentDensity" => ElectricCurrentDensity.From(value, ElectricCurrentDensity.BaseUnit), + "ElectricCurrentGradient" => ElectricCurrentGradient.From(value, ElectricCurrentGradient.BaseUnit), + "ElectricField" => ElectricField.From(value, ElectricField.BaseUnit), + "ElectricInductance" => ElectricInductance.From(value, ElectricInductance.BaseUnit), + "ElectricPotential" => ElectricPotential.From(value, ElectricPotential.BaseUnit), + "ElectricPotentialAc" => ElectricPotentialAc.From(value, ElectricPotentialAc.BaseUnit), + "ElectricPotentialChangeRate" => ElectricPotentialChangeRate.From(value, ElectricPotentialChangeRate.BaseUnit), + "ElectricPotentialDc" => ElectricPotentialDc.From(value, ElectricPotentialDc.BaseUnit), + "ElectricResistance" => ElectricResistance.From(value, ElectricResistance.BaseUnit), + "ElectricResistivity" => ElectricResistivity.From(value, ElectricResistivity.BaseUnit), + "ElectricSurfaceChargeDensity" => ElectricSurfaceChargeDensity.From(value, ElectricSurfaceChargeDensity.BaseUnit), + "Energy" => Energy.From(value, Energy.BaseUnit), + "Entropy" => Entropy.From(value, Entropy.BaseUnit), + "Force" => Force.From(value, Force.BaseUnit), + "ForceChangeRate" => ForceChangeRate.From(value, ForceChangeRate.BaseUnit), + "ForcePerLength" => ForcePerLength.From(value, ForcePerLength.BaseUnit), + "Frequency" => Frequency.From(value, Frequency.BaseUnit), + "FuelEfficiency" => FuelEfficiency.From(value, FuelEfficiency.BaseUnit), + "HeatFlux" => HeatFlux.From(value, HeatFlux.BaseUnit), + "HeatTransferCoefficient" => HeatTransferCoefficient.From(value, HeatTransferCoefficient.BaseUnit), + "Illuminance" => Illuminance.From(value, Illuminance.BaseUnit), + "Information" => Information.From(value, Information.BaseUnit), + "Irradiance" => Irradiance.From(value, Irradiance.BaseUnit), + "Irradiation" => Irradiation.From(value, Irradiation.BaseUnit), + "KinematicViscosity" => KinematicViscosity.From(value, KinematicViscosity.BaseUnit), + "LapseRate" => LapseRate.From(value, LapseRate.BaseUnit), + "Length" => Length.From(value, Length.BaseUnit), + "Level" => Level.From(value, Level.BaseUnit), + "LinearDensity" => LinearDensity.From(value, LinearDensity.BaseUnit), + "LinearPowerDensity" => LinearPowerDensity.From(value, LinearPowerDensity.BaseUnit), + "Luminosity" => Luminosity.From(value, Luminosity.BaseUnit), + "LuminousFlux" => LuminousFlux.From(value, LuminousFlux.BaseUnit), + "LuminousIntensity" => LuminousIntensity.From(value, LuminousIntensity.BaseUnit), + "MagneticField" => MagneticField.From(value, MagneticField.BaseUnit), + "MagneticFlux" => MagneticFlux.From(value, MagneticFlux.BaseUnit), + "Magnetization" => Magnetization.From(value, Magnetization.BaseUnit), + "Mass" => Mass.From(value, Mass.BaseUnit), + "MassConcentration" => MassConcentration.From(value, MassConcentration.BaseUnit), + "MassFlow" => MassFlow.From(value, MassFlow.BaseUnit), + "MassFlux" => MassFlux.From(value, MassFlux.BaseUnit), + "MassFraction" => MassFraction.From(value, MassFraction.BaseUnit), + "MassMomentOfInertia" => MassMomentOfInertia.From(value, MassMomentOfInertia.BaseUnit), + "MolarEnergy" => MolarEnergy.From(value, MolarEnergy.BaseUnit), + "MolarEntropy" => MolarEntropy.From(value, MolarEntropy.BaseUnit), + "Molarity" => Molarity.From(value, Molarity.BaseUnit), + "MolarMass" => MolarMass.From(value, MolarMass.BaseUnit), + "Permeability" => Permeability.From(value, Permeability.BaseUnit), + "Permittivity" => Permittivity.From(value, Permittivity.BaseUnit), + "Power" => Power.From(value, Power.BaseUnit), + "PowerDensity" => PowerDensity.From(value, PowerDensity.BaseUnit), + "PowerRatio" => PowerRatio.From(value, PowerRatio.BaseUnit), + "Pressure" => Pressure.From(value, Pressure.BaseUnit), + "PressureChangeRate" => PressureChangeRate.From(value, PressureChangeRate.BaseUnit), + "Ratio" => Ratio.From(value, Ratio.BaseUnit), + "RatioChangeRate" => RatioChangeRate.From(value, RatioChangeRate.BaseUnit), + "ReactiveEnergy" => ReactiveEnergy.From(value, ReactiveEnergy.BaseUnit), + "ReactivePower" => ReactivePower.From(value, ReactivePower.BaseUnit), + "ReciprocalArea" => ReciprocalArea.From(value, ReciprocalArea.BaseUnit), + "ReciprocalLength" => ReciprocalLength.From(value, ReciprocalLength.BaseUnit), + "RelativeHumidity" => RelativeHumidity.From(value, RelativeHumidity.BaseUnit), + "RotationalAcceleration" => RotationalAcceleration.From(value, RotationalAcceleration.BaseUnit), + "RotationalSpeed" => RotationalSpeed.From(value, RotationalSpeed.BaseUnit), + "RotationalStiffness" => RotationalStiffness.From(value, RotationalStiffness.BaseUnit), + "RotationalStiffnessPerLength" => RotationalStiffnessPerLength.From(value, RotationalStiffnessPerLength.BaseUnit), + "Scalar" => Scalar.From(value, Scalar.BaseUnit), + "SolidAngle" => SolidAngle.From(value, SolidAngle.BaseUnit), + "SpecificEnergy" => SpecificEnergy.From(value, SpecificEnergy.BaseUnit), + "SpecificEntropy" => SpecificEntropy.From(value, SpecificEntropy.BaseUnit), + "SpecificFuelConsumption" => SpecificFuelConsumption.From(value, SpecificFuelConsumption.BaseUnit), + "SpecificVolume" => SpecificVolume.From(value, SpecificVolume.BaseUnit), + "SpecificWeight" => SpecificWeight.From(value, SpecificWeight.BaseUnit), + "Speed" => Speed.From(value, Speed.BaseUnit), + "StandardVolumeFlow" => StandardVolumeFlow.From(value, StandardVolumeFlow.BaseUnit), + "Temperature" => Temperature.From(value, Temperature.BaseUnit), + "TemperatureChangeRate" => TemperatureChangeRate.From(value, TemperatureChangeRate.BaseUnit), + "TemperatureDelta" => TemperatureDelta.From(value, TemperatureDelta.BaseUnit), + "TemperatureGradient" => TemperatureGradient.From(value, TemperatureGradient.BaseUnit), + "ThermalConductivity" => ThermalConductivity.From(value, ThermalConductivity.BaseUnit), + "ThermalResistance" => ThermalResistance.From(value, ThermalResistance.BaseUnit), + "Torque" => Torque.From(value, Torque.BaseUnit), + "TorquePerLength" => TorquePerLength.From(value, TorquePerLength.BaseUnit), + "Turbidity" => Turbidity.From(value, Turbidity.BaseUnit), + "VitaminA" => VitaminA.From(value, VitaminA.BaseUnit), + "Volume" => Volume.From(value, Volume.BaseUnit), + "VolumeConcentration" => VolumeConcentration.From(value, VolumeConcentration.BaseUnit), + "VolumeFlow" => VolumeFlow.From(value, VolumeFlow.BaseUnit), + "VolumeFlowPerArea" => VolumeFlowPerArea.From(value, VolumeFlowPerArea.BaseUnit), + "VolumePerLength" => VolumePerLength.From(value, VolumePerLength.BaseUnit), + "VolumetricHeatCapacity" => VolumetricHeatCapacity.From(value, VolumetricHeatCapacity.BaseUnit), + "WarpingMomentOfInertia" => WarpingMomentOfInertia.From(value, WarpingMomentOfInertia.BaseUnit), + _ => throw new ArgumentException($"{quantityInfo.Name} is not a supported quantity.") + }; } /// @@ -1003,235 +777,122 @@ public static bool TryParse(IFormatProvider? formatProvider, Type quantityType, var parser = QuantityParser.Default; - switch(quantityType) + return quantityType switch { - case Type _ when quantityType == typeof(Acceleration): - return parser.TryParse(quantityString, formatProvider, Acceleration.From, out quantity); - case Type _ when quantityType == typeof(AmountOfSubstance): - return parser.TryParse(quantityString, formatProvider, AmountOfSubstance.From, out quantity); - case Type _ when quantityType == typeof(AmplitudeRatio): - return parser.TryParse(quantityString, formatProvider, AmplitudeRatio.From, out quantity); - case Type _ when quantityType == typeof(Angle): - return parser.TryParse(quantityString, formatProvider, Angle.From, out quantity); - case Type _ when quantityType == typeof(ApparentEnergy): - return parser.TryParse(quantityString, formatProvider, ApparentEnergy.From, out quantity); - case Type _ when quantityType == typeof(ApparentPower): - return parser.TryParse(quantityString, formatProvider, ApparentPower.From, out quantity); - case Type _ when quantityType == typeof(Area): - return parser.TryParse(quantityString, formatProvider, Area.From, out quantity); - case Type _ when quantityType == typeof(AreaDensity): - return parser.TryParse(quantityString, formatProvider, AreaDensity.From, out quantity); - case Type _ when quantityType == typeof(AreaMomentOfInertia): - return parser.TryParse(quantityString, formatProvider, AreaMomentOfInertia.From, out quantity); - case Type _ when quantityType == typeof(BitRate): - return parser.TryParse(quantityString, formatProvider, BitRate.From, out quantity); - case Type _ when quantityType == typeof(BrakeSpecificFuelConsumption): - return parser.TryParse(quantityString, formatProvider, BrakeSpecificFuelConsumption.From, out quantity); - case Type _ when quantityType == typeof(Capacitance): - return parser.TryParse(quantityString, formatProvider, Capacitance.From, out quantity); - case Type _ when quantityType == typeof(CoefficientOfThermalExpansion): - return parser.TryParse(quantityString, formatProvider, CoefficientOfThermalExpansion.From, out quantity); - case Type _ when quantityType == typeof(Density): - return parser.TryParse(quantityString, formatProvider, Density.From, out quantity); - case Type _ when quantityType == typeof(Duration): - return parser.TryParse(quantityString, formatProvider, Duration.From, out quantity); - case Type _ when quantityType == typeof(DynamicViscosity): - return parser.TryParse(quantityString, formatProvider, DynamicViscosity.From, out quantity); - case Type _ when quantityType == typeof(ElectricAdmittance): - return parser.TryParse(quantityString, formatProvider, ElectricAdmittance.From, out quantity); - case Type _ when quantityType == typeof(ElectricCharge): - return parser.TryParse(quantityString, formatProvider, ElectricCharge.From, out quantity); - case Type _ when quantityType == typeof(ElectricChargeDensity): - return parser.TryParse(quantityString, formatProvider, ElectricChargeDensity.From, out quantity); - case Type _ when quantityType == typeof(ElectricConductance): - return parser.TryParse(quantityString, formatProvider, ElectricConductance.From, out quantity); - case Type _ when quantityType == typeof(ElectricConductivity): - return parser.TryParse(quantityString, formatProvider, ElectricConductivity.From, out quantity); - case Type _ when quantityType == typeof(ElectricCurrent): - return parser.TryParse(quantityString, formatProvider, ElectricCurrent.From, out quantity); - case Type _ when quantityType == typeof(ElectricCurrentDensity): - return parser.TryParse(quantityString, formatProvider, ElectricCurrentDensity.From, out quantity); - case Type _ when quantityType == typeof(ElectricCurrentGradient): - return parser.TryParse(quantityString, formatProvider, ElectricCurrentGradient.From, out quantity); - case Type _ when quantityType == typeof(ElectricField): - return parser.TryParse(quantityString, formatProvider, ElectricField.From, out quantity); - case Type _ when quantityType == typeof(ElectricInductance): - return parser.TryParse(quantityString, formatProvider, ElectricInductance.From, out quantity); - case Type _ when quantityType == typeof(ElectricPotential): - return parser.TryParse(quantityString, formatProvider, ElectricPotential.From, out quantity); - case Type _ when quantityType == typeof(ElectricPotentialAc): - return parser.TryParse(quantityString, formatProvider, ElectricPotentialAc.From, out quantity); - case Type _ when quantityType == typeof(ElectricPotentialChangeRate): - return parser.TryParse(quantityString, formatProvider, ElectricPotentialChangeRate.From, out quantity); - case Type _ when quantityType == typeof(ElectricPotentialDc): - return parser.TryParse(quantityString, formatProvider, ElectricPotentialDc.From, out quantity); - case Type _ when quantityType == typeof(ElectricResistance): - return parser.TryParse(quantityString, formatProvider, ElectricResistance.From, out quantity); - case Type _ when quantityType == typeof(ElectricResistivity): - return parser.TryParse(quantityString, formatProvider, ElectricResistivity.From, out quantity); - case Type _ when quantityType == typeof(ElectricSurfaceChargeDensity): - return parser.TryParse(quantityString, formatProvider, ElectricSurfaceChargeDensity.From, out quantity); - case Type _ when quantityType == typeof(Energy): - return parser.TryParse(quantityString, formatProvider, Energy.From, out quantity); - case Type _ when quantityType == typeof(Entropy): - return parser.TryParse(quantityString, formatProvider, Entropy.From, out quantity); - case Type _ when quantityType == typeof(Force): - return parser.TryParse(quantityString, formatProvider, Force.From, out quantity); - case Type _ when quantityType == typeof(ForceChangeRate): - return parser.TryParse(quantityString, formatProvider, ForceChangeRate.From, out quantity); - case Type _ when quantityType == typeof(ForcePerLength): - return parser.TryParse(quantityString, formatProvider, ForcePerLength.From, out quantity); - case Type _ when quantityType == typeof(Frequency): - return parser.TryParse(quantityString, formatProvider, Frequency.From, out quantity); - case Type _ when quantityType == typeof(FuelEfficiency): - return parser.TryParse(quantityString, formatProvider, FuelEfficiency.From, out quantity); - case Type _ when quantityType == typeof(HeatFlux): - return parser.TryParse(quantityString, formatProvider, HeatFlux.From, out quantity); - case Type _ when quantityType == typeof(HeatTransferCoefficient): - return parser.TryParse(quantityString, formatProvider, HeatTransferCoefficient.From, out quantity); - case Type _ when quantityType == typeof(Illuminance): - return parser.TryParse(quantityString, formatProvider, Illuminance.From, out quantity); - case Type _ when quantityType == typeof(Information): - return parser.TryParse(quantityString, formatProvider, Information.From, out quantity); - case Type _ when quantityType == typeof(Irradiance): - return parser.TryParse(quantityString, formatProvider, Irradiance.From, out quantity); - case Type _ when quantityType == typeof(Irradiation): - return parser.TryParse(quantityString, formatProvider, Irradiation.From, out quantity); - case Type _ when quantityType == typeof(KinematicViscosity): - return parser.TryParse(quantityString, formatProvider, KinematicViscosity.From, out quantity); - case Type _ when quantityType == typeof(LapseRate): - return parser.TryParse(quantityString, formatProvider, LapseRate.From, out quantity); - case Type _ when quantityType == typeof(Length): - return parser.TryParse(quantityString, formatProvider, Length.From, out quantity); - case Type _ when quantityType == typeof(Level): - return parser.TryParse(quantityString, formatProvider, Level.From, out quantity); - case Type _ when quantityType == typeof(LinearDensity): - return parser.TryParse(quantityString, formatProvider, LinearDensity.From, out quantity); - case Type _ when quantityType == typeof(LinearPowerDensity): - return parser.TryParse(quantityString, formatProvider, LinearPowerDensity.From, out quantity); - case Type _ when quantityType == typeof(Luminosity): - return parser.TryParse(quantityString, formatProvider, Luminosity.From, out quantity); - case Type _ when quantityType == typeof(LuminousFlux): - return parser.TryParse(quantityString, formatProvider, LuminousFlux.From, out quantity); - case Type _ when quantityType == typeof(LuminousIntensity): - return parser.TryParse(quantityString, formatProvider, LuminousIntensity.From, out quantity); - case Type _ when quantityType == typeof(MagneticField): - return parser.TryParse(quantityString, formatProvider, MagneticField.From, out quantity); - case Type _ when quantityType == typeof(MagneticFlux): - return parser.TryParse(quantityString, formatProvider, MagneticFlux.From, out quantity); - case Type _ when quantityType == typeof(Magnetization): - return parser.TryParse(quantityString, formatProvider, Magnetization.From, out quantity); - case Type _ when quantityType == typeof(Mass): - return parser.TryParse(quantityString, formatProvider, Mass.From, out quantity); - case Type _ when quantityType == typeof(MassConcentration): - return parser.TryParse(quantityString, formatProvider, MassConcentration.From, out quantity); - case Type _ when quantityType == typeof(MassFlow): - return parser.TryParse(quantityString, formatProvider, MassFlow.From, out quantity); - case Type _ when quantityType == typeof(MassFlux): - return parser.TryParse(quantityString, formatProvider, MassFlux.From, out quantity); - case Type _ when quantityType == typeof(MassFraction): - return parser.TryParse(quantityString, formatProvider, MassFraction.From, out quantity); - case Type _ when quantityType == typeof(MassMomentOfInertia): - return parser.TryParse(quantityString, formatProvider, MassMomentOfInertia.From, out quantity); - case Type _ when quantityType == typeof(MolarEnergy): - return parser.TryParse(quantityString, formatProvider, MolarEnergy.From, out quantity); - case Type _ when quantityType == typeof(MolarEntropy): - return parser.TryParse(quantityString, formatProvider, MolarEntropy.From, out quantity); - case Type _ when quantityType == typeof(Molarity): - return parser.TryParse(quantityString, formatProvider, Molarity.From, out quantity); - case Type _ when quantityType == typeof(MolarMass): - return parser.TryParse(quantityString, formatProvider, MolarMass.From, out quantity); - case Type _ when quantityType == typeof(Permeability): - return parser.TryParse(quantityString, formatProvider, Permeability.From, out quantity); - case Type _ when quantityType == typeof(Permittivity): - return parser.TryParse(quantityString, formatProvider, Permittivity.From, out quantity); - case Type _ when quantityType == typeof(Power): - return parser.TryParse(quantityString, formatProvider, Power.From, out quantity); - case Type _ when quantityType == typeof(PowerDensity): - return parser.TryParse(quantityString, formatProvider, PowerDensity.From, out quantity); - case Type _ when quantityType == typeof(PowerRatio): - return parser.TryParse(quantityString, formatProvider, PowerRatio.From, out quantity); - case Type _ when quantityType == typeof(Pressure): - return parser.TryParse(quantityString, formatProvider, Pressure.From, out quantity); - case Type _ when quantityType == typeof(PressureChangeRate): - return parser.TryParse(quantityString, formatProvider, PressureChangeRate.From, out quantity); - case Type _ when quantityType == typeof(Ratio): - return parser.TryParse(quantityString, formatProvider, Ratio.From, out quantity); - case Type _ when quantityType == typeof(RatioChangeRate): - return parser.TryParse(quantityString, formatProvider, RatioChangeRate.From, out quantity); - case Type _ when quantityType == typeof(ReactiveEnergy): - return parser.TryParse(quantityString, formatProvider, ReactiveEnergy.From, out quantity); - case Type _ when quantityType == typeof(ReactivePower): - return parser.TryParse(quantityString, formatProvider, ReactivePower.From, out quantity); - case Type _ when quantityType == typeof(ReciprocalArea): - return parser.TryParse(quantityString, formatProvider, ReciprocalArea.From, out quantity); - case Type _ when quantityType == typeof(ReciprocalLength): - return parser.TryParse(quantityString, formatProvider, ReciprocalLength.From, out quantity); - case Type _ when quantityType == typeof(RelativeHumidity): - return parser.TryParse(quantityString, formatProvider, RelativeHumidity.From, out quantity); - case Type _ when quantityType == typeof(RotationalAcceleration): - return parser.TryParse(quantityString, formatProvider, RotationalAcceleration.From, out quantity); - case Type _ when quantityType == typeof(RotationalSpeed): - return parser.TryParse(quantityString, formatProvider, RotationalSpeed.From, out quantity); - case Type _ when quantityType == typeof(RotationalStiffness): - return parser.TryParse(quantityString, formatProvider, RotationalStiffness.From, out quantity); - case Type _ when quantityType == typeof(RotationalStiffnessPerLength): - return parser.TryParse(quantityString, formatProvider, RotationalStiffnessPerLength.From, out quantity); - case Type _ when quantityType == typeof(Scalar): - return parser.TryParse(quantityString, formatProvider, Scalar.From, out quantity); - case Type _ when quantityType == typeof(SolidAngle): - return parser.TryParse(quantityString, formatProvider, SolidAngle.From, out quantity); - case Type _ when quantityType == typeof(SpecificEnergy): - return parser.TryParse(quantityString, formatProvider, SpecificEnergy.From, out quantity); - case Type _ when quantityType == typeof(SpecificEntropy): - return parser.TryParse(quantityString, formatProvider, SpecificEntropy.From, out quantity); - case Type _ when quantityType == typeof(SpecificFuelConsumption): - return parser.TryParse(quantityString, formatProvider, SpecificFuelConsumption.From, out quantity); - case Type _ when quantityType == typeof(SpecificVolume): - return parser.TryParse(quantityString, formatProvider, SpecificVolume.From, out quantity); - case Type _ when quantityType == typeof(SpecificWeight): - return parser.TryParse(quantityString, formatProvider, SpecificWeight.From, out quantity); - case Type _ when quantityType == typeof(Speed): - return parser.TryParse(quantityString, formatProvider, Speed.From, out quantity); - case Type _ when quantityType == typeof(StandardVolumeFlow): - return parser.TryParse(quantityString, formatProvider, StandardVolumeFlow.From, out quantity); - case Type _ when quantityType == typeof(Temperature): - return parser.TryParse(quantityString, formatProvider, Temperature.From, out quantity); - case Type _ when quantityType == typeof(TemperatureChangeRate): - return parser.TryParse(quantityString, formatProvider, TemperatureChangeRate.From, out quantity); - case Type _ when quantityType == typeof(TemperatureDelta): - return parser.TryParse(quantityString, formatProvider, TemperatureDelta.From, out quantity); - case Type _ when quantityType == typeof(TemperatureGradient): - return parser.TryParse(quantityString, formatProvider, TemperatureGradient.From, out quantity); - case Type _ when quantityType == typeof(ThermalConductivity): - return parser.TryParse(quantityString, formatProvider, ThermalConductivity.From, out quantity); - case Type _ when quantityType == typeof(ThermalResistance): - return parser.TryParse(quantityString, formatProvider, ThermalResistance.From, out quantity); - case Type _ when quantityType == typeof(Torque): - return parser.TryParse(quantityString, formatProvider, Torque.From, out quantity); - case Type _ when quantityType == typeof(TorquePerLength): - return parser.TryParse(quantityString, formatProvider, TorquePerLength.From, out quantity); - case Type _ when quantityType == typeof(Turbidity): - return parser.TryParse(quantityString, formatProvider, Turbidity.From, out quantity); - case Type _ when quantityType == typeof(VitaminA): - return parser.TryParse(quantityString, formatProvider, VitaminA.From, out quantity); - case Type _ when quantityType == typeof(Volume): - return parser.TryParse(quantityString, formatProvider, Volume.From, out quantity); - case Type _ when quantityType == typeof(VolumeConcentration): - return parser.TryParse(quantityString, formatProvider, VolumeConcentration.From, out quantity); - case Type _ when quantityType == typeof(VolumeFlow): - return parser.TryParse(quantityString, formatProvider, VolumeFlow.From, out quantity); - case Type _ when quantityType == typeof(VolumeFlowPerArea): - return parser.TryParse(quantityString, formatProvider, VolumeFlowPerArea.From, out quantity); - case Type _ when quantityType == typeof(VolumePerLength): - return parser.TryParse(quantityString, formatProvider, VolumePerLength.From, out quantity); - case Type _ when quantityType == typeof(VolumetricHeatCapacity): - return parser.TryParse(quantityString, formatProvider, VolumetricHeatCapacity.From, out quantity); - case Type _ when quantityType == typeof(WarpingMomentOfInertia): - return parser.TryParse(quantityString, formatProvider, WarpingMomentOfInertia.From, out quantity); - default: - return false; - } + Type _ when quantityType == typeof(Acceleration) => parser.TryParse(quantityString, formatProvider, Acceleration.From, out quantity), + Type _ when quantityType == typeof(AmountOfSubstance) => parser.TryParse(quantityString, formatProvider, AmountOfSubstance.From, out quantity), + Type _ when quantityType == typeof(AmplitudeRatio) => parser.TryParse(quantityString, formatProvider, AmplitudeRatio.From, out quantity), + Type _ when quantityType == typeof(Angle) => parser.TryParse(quantityString, formatProvider, Angle.From, out quantity), + Type _ when quantityType == typeof(ApparentEnergy) => parser.TryParse(quantityString, formatProvider, ApparentEnergy.From, out quantity), + Type _ when quantityType == typeof(ApparentPower) => parser.TryParse(quantityString, formatProvider, ApparentPower.From, out quantity), + Type _ when quantityType == typeof(Area) => parser.TryParse(quantityString, formatProvider, Area.From, out quantity), + Type _ when quantityType == typeof(AreaDensity) => parser.TryParse(quantityString, formatProvider, AreaDensity.From, out quantity), + Type _ when quantityType == typeof(AreaMomentOfInertia) => parser.TryParse(quantityString, formatProvider, AreaMomentOfInertia.From, out quantity), + Type _ when quantityType == typeof(BitRate) => parser.TryParse(quantityString, formatProvider, BitRate.From, out quantity), + Type _ when quantityType == typeof(BrakeSpecificFuelConsumption) => parser.TryParse(quantityString, formatProvider, BrakeSpecificFuelConsumption.From, out quantity), + Type _ when quantityType == typeof(Capacitance) => parser.TryParse(quantityString, formatProvider, Capacitance.From, out quantity), + Type _ when quantityType == typeof(CoefficientOfThermalExpansion) => parser.TryParse(quantityString, formatProvider, CoefficientOfThermalExpansion.From, out quantity), + Type _ when quantityType == typeof(Density) => parser.TryParse(quantityString, formatProvider, Density.From, out quantity), + Type _ when quantityType == typeof(Duration) => parser.TryParse(quantityString, formatProvider, Duration.From, out quantity), + Type _ when quantityType == typeof(DynamicViscosity) => parser.TryParse(quantityString, formatProvider, DynamicViscosity.From, out quantity), + Type _ when quantityType == typeof(ElectricAdmittance) => parser.TryParse(quantityString, formatProvider, ElectricAdmittance.From, out quantity), + Type _ when quantityType == typeof(ElectricCharge) => parser.TryParse(quantityString, formatProvider, ElectricCharge.From, out quantity), + Type _ when quantityType == typeof(ElectricChargeDensity) => parser.TryParse(quantityString, formatProvider, ElectricChargeDensity.From, out quantity), + Type _ when quantityType == typeof(ElectricConductance) => parser.TryParse(quantityString, formatProvider, ElectricConductance.From, out quantity), + Type _ when quantityType == typeof(ElectricConductivity) => parser.TryParse(quantityString, formatProvider, ElectricConductivity.From, out quantity), + Type _ when quantityType == typeof(ElectricCurrent) => parser.TryParse(quantityString, formatProvider, ElectricCurrent.From, out quantity), + Type _ when quantityType == typeof(ElectricCurrentDensity) => parser.TryParse(quantityString, formatProvider, ElectricCurrentDensity.From, out quantity), + Type _ when quantityType == typeof(ElectricCurrentGradient) => parser.TryParse(quantityString, formatProvider, ElectricCurrentGradient.From, out quantity), + Type _ when quantityType == typeof(ElectricField) => parser.TryParse(quantityString, formatProvider, ElectricField.From, out quantity), + Type _ when quantityType == typeof(ElectricInductance) => parser.TryParse(quantityString, formatProvider, ElectricInductance.From, out quantity), + Type _ when quantityType == typeof(ElectricPotential) => parser.TryParse(quantityString, formatProvider, ElectricPotential.From, out quantity), + Type _ when quantityType == typeof(ElectricPotentialAc) => parser.TryParse(quantityString, formatProvider, ElectricPotentialAc.From, out quantity), + Type _ when quantityType == typeof(ElectricPotentialChangeRate) => parser.TryParse(quantityString, formatProvider, ElectricPotentialChangeRate.From, out quantity), + Type _ when quantityType == typeof(ElectricPotentialDc) => parser.TryParse(quantityString, formatProvider, ElectricPotentialDc.From, out quantity), + Type _ when quantityType == typeof(ElectricResistance) => parser.TryParse(quantityString, formatProvider, ElectricResistance.From, out quantity), + Type _ when quantityType == typeof(ElectricResistivity) => parser.TryParse(quantityString, formatProvider, ElectricResistivity.From, out quantity), + Type _ when quantityType == typeof(ElectricSurfaceChargeDensity) => parser.TryParse(quantityString, formatProvider, ElectricSurfaceChargeDensity.From, out quantity), + Type _ when quantityType == typeof(Energy) => parser.TryParse(quantityString, formatProvider, Energy.From, out quantity), + Type _ when quantityType == typeof(Entropy) => parser.TryParse(quantityString, formatProvider, Entropy.From, out quantity), + Type _ when quantityType == typeof(Force) => parser.TryParse(quantityString, formatProvider, Force.From, out quantity), + Type _ when quantityType == typeof(ForceChangeRate) => parser.TryParse(quantityString, formatProvider, ForceChangeRate.From, out quantity), + Type _ when quantityType == typeof(ForcePerLength) => parser.TryParse(quantityString, formatProvider, ForcePerLength.From, out quantity), + Type _ when quantityType == typeof(Frequency) => parser.TryParse(quantityString, formatProvider, Frequency.From, out quantity), + Type _ when quantityType == typeof(FuelEfficiency) => parser.TryParse(quantityString, formatProvider, FuelEfficiency.From, out quantity), + Type _ when quantityType == typeof(HeatFlux) => parser.TryParse(quantityString, formatProvider, HeatFlux.From, out quantity), + Type _ when quantityType == typeof(HeatTransferCoefficient) => parser.TryParse(quantityString, formatProvider, HeatTransferCoefficient.From, out quantity), + Type _ when quantityType == typeof(Illuminance) => parser.TryParse(quantityString, formatProvider, Illuminance.From, out quantity), + Type _ when quantityType == typeof(Information) => parser.TryParse(quantityString, formatProvider, Information.From, out quantity), + Type _ when quantityType == typeof(Irradiance) => parser.TryParse(quantityString, formatProvider, Irradiance.From, out quantity), + Type _ when quantityType == typeof(Irradiation) => parser.TryParse(quantityString, formatProvider, Irradiation.From, out quantity), + Type _ when quantityType == typeof(KinematicViscosity) => parser.TryParse(quantityString, formatProvider, KinematicViscosity.From, out quantity), + Type _ when quantityType == typeof(LapseRate) => parser.TryParse(quantityString, formatProvider, LapseRate.From, out quantity), + Type _ when quantityType == typeof(Length) => parser.TryParse(quantityString, formatProvider, Length.From, out quantity), + Type _ when quantityType == typeof(Level) => parser.TryParse(quantityString, formatProvider, Level.From, out quantity), + Type _ when quantityType == typeof(LinearDensity) => parser.TryParse(quantityString, formatProvider, LinearDensity.From, out quantity), + Type _ when quantityType == typeof(LinearPowerDensity) => parser.TryParse(quantityString, formatProvider, LinearPowerDensity.From, out quantity), + Type _ when quantityType == typeof(Luminosity) => parser.TryParse(quantityString, formatProvider, Luminosity.From, out quantity), + Type _ when quantityType == typeof(LuminousFlux) => parser.TryParse(quantityString, formatProvider, LuminousFlux.From, out quantity), + Type _ when quantityType == typeof(LuminousIntensity) => parser.TryParse(quantityString, formatProvider, LuminousIntensity.From, out quantity), + Type _ when quantityType == typeof(MagneticField) => parser.TryParse(quantityString, formatProvider, MagneticField.From, out quantity), + Type _ when quantityType == typeof(MagneticFlux) => parser.TryParse(quantityString, formatProvider, MagneticFlux.From, out quantity), + Type _ when quantityType == typeof(Magnetization) => parser.TryParse(quantityString, formatProvider, Magnetization.From, out quantity), + Type _ when quantityType == typeof(Mass) => parser.TryParse(quantityString, formatProvider, Mass.From, out quantity), + Type _ when quantityType == typeof(MassConcentration) => parser.TryParse(quantityString, formatProvider, MassConcentration.From, out quantity), + Type _ when quantityType == typeof(MassFlow) => parser.TryParse(quantityString, formatProvider, MassFlow.From, out quantity), + Type _ when quantityType == typeof(MassFlux) => parser.TryParse(quantityString, formatProvider, MassFlux.From, out quantity), + Type _ when quantityType == typeof(MassFraction) => parser.TryParse(quantityString, formatProvider, MassFraction.From, out quantity), + Type _ when quantityType == typeof(MassMomentOfInertia) => parser.TryParse(quantityString, formatProvider, MassMomentOfInertia.From, out quantity), + Type _ when quantityType == typeof(MolarEnergy) => parser.TryParse(quantityString, formatProvider, MolarEnergy.From, out quantity), + Type _ when quantityType == typeof(MolarEntropy) => parser.TryParse(quantityString, formatProvider, MolarEntropy.From, out quantity), + Type _ when quantityType == typeof(Molarity) => parser.TryParse(quantityString, formatProvider, Molarity.From, out quantity), + Type _ when quantityType == typeof(MolarMass) => parser.TryParse(quantityString, formatProvider, MolarMass.From, out quantity), + Type _ when quantityType == typeof(Permeability) => parser.TryParse(quantityString, formatProvider, Permeability.From, out quantity), + Type _ when quantityType == typeof(Permittivity) => parser.TryParse(quantityString, formatProvider, Permittivity.From, out quantity), + Type _ when quantityType == typeof(Power) => parser.TryParse(quantityString, formatProvider, Power.From, out quantity), + Type _ when quantityType == typeof(PowerDensity) => parser.TryParse(quantityString, formatProvider, PowerDensity.From, out quantity), + Type _ when quantityType == typeof(PowerRatio) => parser.TryParse(quantityString, formatProvider, PowerRatio.From, out quantity), + Type _ when quantityType == typeof(Pressure) => parser.TryParse(quantityString, formatProvider, Pressure.From, out quantity), + Type _ when quantityType == typeof(PressureChangeRate) => parser.TryParse(quantityString, formatProvider, PressureChangeRate.From, out quantity), + Type _ when quantityType == typeof(Ratio) => parser.TryParse(quantityString, formatProvider, Ratio.From, out quantity), + Type _ when quantityType == typeof(RatioChangeRate) => parser.TryParse(quantityString, formatProvider, RatioChangeRate.From, out quantity), + Type _ when quantityType == typeof(ReactiveEnergy) => parser.TryParse(quantityString, formatProvider, ReactiveEnergy.From, out quantity), + Type _ when quantityType == typeof(ReactivePower) => parser.TryParse(quantityString, formatProvider, ReactivePower.From, out quantity), + Type _ when quantityType == typeof(ReciprocalArea) => parser.TryParse(quantityString, formatProvider, ReciprocalArea.From, out quantity), + Type _ when quantityType == typeof(ReciprocalLength) => parser.TryParse(quantityString, formatProvider, ReciprocalLength.From, out quantity), + Type _ when quantityType == typeof(RelativeHumidity) => parser.TryParse(quantityString, formatProvider, RelativeHumidity.From, out quantity), + Type _ when quantityType == typeof(RotationalAcceleration) => parser.TryParse(quantityString, formatProvider, RotationalAcceleration.From, out quantity), + Type _ when quantityType == typeof(RotationalSpeed) => parser.TryParse(quantityString, formatProvider, RotationalSpeed.From, out quantity), + Type _ when quantityType == typeof(RotationalStiffness) => parser.TryParse(quantityString, formatProvider, RotationalStiffness.From, out quantity), + Type _ when quantityType == typeof(RotationalStiffnessPerLength) => parser.TryParse(quantityString, formatProvider, RotationalStiffnessPerLength.From, out quantity), + Type _ when quantityType == typeof(Scalar) => parser.TryParse(quantityString, formatProvider, Scalar.From, out quantity), + Type _ when quantityType == typeof(SolidAngle) => parser.TryParse(quantityString, formatProvider, SolidAngle.From, out quantity), + Type _ when quantityType == typeof(SpecificEnergy) => parser.TryParse(quantityString, formatProvider, SpecificEnergy.From, out quantity), + Type _ when quantityType == typeof(SpecificEntropy) => parser.TryParse(quantityString, formatProvider, SpecificEntropy.From, out quantity), + Type _ when quantityType == typeof(SpecificFuelConsumption) => parser.TryParse(quantityString, formatProvider, SpecificFuelConsumption.From, out quantity), + Type _ when quantityType == typeof(SpecificVolume) => parser.TryParse(quantityString, formatProvider, SpecificVolume.From, out quantity), + Type _ when quantityType == typeof(SpecificWeight) => parser.TryParse(quantityString, formatProvider, SpecificWeight.From, out quantity), + Type _ when quantityType == typeof(Speed) => parser.TryParse(quantityString, formatProvider, Speed.From, out quantity), + Type _ when quantityType == typeof(StandardVolumeFlow) => parser.TryParse(quantityString, formatProvider, StandardVolumeFlow.From, out quantity), + Type _ when quantityType == typeof(Temperature) => parser.TryParse(quantityString, formatProvider, Temperature.From, out quantity), + Type _ when quantityType == typeof(TemperatureChangeRate) => parser.TryParse(quantityString, formatProvider, TemperatureChangeRate.From, out quantity), + Type _ when quantityType == typeof(TemperatureDelta) => parser.TryParse(quantityString, formatProvider, TemperatureDelta.From, out quantity), + Type _ when quantityType == typeof(TemperatureGradient) => parser.TryParse(quantityString, formatProvider, TemperatureGradient.From, out quantity), + Type _ when quantityType == typeof(ThermalConductivity) => parser.TryParse(quantityString, formatProvider, ThermalConductivity.From, out quantity), + Type _ when quantityType == typeof(ThermalResistance) => parser.TryParse(quantityString, formatProvider, ThermalResistance.From, out quantity), + Type _ when quantityType == typeof(Torque) => parser.TryParse(quantityString, formatProvider, Torque.From, out quantity), + Type _ when quantityType == typeof(TorquePerLength) => parser.TryParse(quantityString, formatProvider, TorquePerLength.From, out quantity), + Type _ when quantityType == typeof(Turbidity) => parser.TryParse(quantityString, formatProvider, Turbidity.From, out quantity), + Type _ when quantityType == typeof(VitaminA) => parser.TryParse(quantityString, formatProvider, VitaminA.From, out quantity), + Type _ when quantityType == typeof(Volume) => parser.TryParse(quantityString, formatProvider, Volume.From, out quantity), + Type _ when quantityType == typeof(VolumeConcentration) => parser.TryParse(quantityString, formatProvider, VolumeConcentration.From, out quantity), + Type _ when quantityType == typeof(VolumeFlow) => parser.TryParse(quantityString, formatProvider, VolumeFlow.From, out quantity), + Type _ when quantityType == typeof(VolumeFlowPerArea) => parser.TryParse(quantityString, formatProvider, VolumeFlowPerArea.From, out quantity), + Type _ when quantityType == typeof(VolumePerLength) => parser.TryParse(quantityString, formatProvider, VolumePerLength.From, out quantity), + Type _ when quantityType == typeof(VolumetricHeatCapacity) => parser.TryParse(quantityString, formatProvider, VolumetricHeatCapacity.From, out quantity), + Type _ when quantityType == typeof(WarpingMomentOfInertia) => parser.TryParse(quantityString, formatProvider, WarpingMomentOfInertia.From, out quantity), + _ => false + }; } internal static IEnumerable GetQuantityTypes()